🚀 S2T-SMALL-LIBRISPEECH-ASR
s2t-small-librispeech-asr
は、自動音声認識(ASR)のために学習された音声からテキストへの変換Transformer(S2T)モデルです。S2Tモデルは この論文 で提案され、このリポジトリ で公開されています。
🚀 クイックスタート
このモデルは、エンドツーエンドの音声認識(ASR)に使用できます。他のS2Tチェックポイントを探すには、モデルハブ を参照してください。
✨ 主な機能
S2TはエンドツーエンドのシーケンスツーシーケンスTransformerモデルです。標準的な自己回帰的クロスエントロピー損失で学習され、自己回帰的に文字起こしを生成します。
📦 インストール
torchaudio
と sentencepiece
パッケージをインストールする必要があります。以下のいずれかの方法でインストールできます。
pip install transformers"[speech, sentencepiece]"
pip install torchaudio sentencepiece
💻 使用例
基本的な使用法
import torch
from transformers import Speech2TextProcessor, Speech2TextForConditionalGeneration
from datasets import load_dataset
model = Speech2TextForConditionalGeneration.from_pretrained("facebook/s2t-small-librispeech-asr")
processor = Speech2TextProcessor.from_pretrained("facebook/s2t-small-librispeech-asr")
ds = load_dataset(
"patrickvonplaten/librispeech_asr_dummy",
"clean",
split="validation"
)
input_features = processor(
ds[0]["audio"]["array"],
sampling_rate=16_000,
return_tensors="pt"
).input_features
generated_ids = model.generate(input_features=input_features)
transcription = processor.batch_decode(generated_ids)
高度な使用法
LibriSpeechテストデータセットでの評価
以下のスクリプトは、このモデルを LibriSpeech の "clean" および "other" テストデータセットで評価する方法を示しています。
from datasets import load_dataset
from evaluate import load
from transformers import Speech2TextForConditionalGeneration, Speech2TextProcessor
librispeech_eval = load_dataset("librispeech_asr", "clean", split="test")
wer = load("wer")
model = Speech2TextForConditionalGeneration.from_pretrained("facebook/s2t-small-librispeech-asr").to("cuda")
processor = Speech2TextProcessor.from_pretrained("facebook/s2t-small-librispeech-asr", do_upper_case=True)
def map_to_pred(batch):
features = processor(batch["audio"]["array"], sampling_rate=16000, padding=True, return_tensors="pt")
input_features = features.input_features.to("cuda")
attention_mask = features.attention_mask.to("cuda")
gen_tokens = model.generate(input_features=input_features, attention_mask=attention_mask)
batch["transcription"] = processor.batch_decode(gen_tokens, skip_special_tokens=True)[0]
return batch
result = librispeech_eval.map(map_to_pred, remove_columns=["audio"])
print("WER:", wer.compute(predictions=result["transcription"], references=result["text"]))
結果(WER):
📚 ドキュメント
学習データ
S2T-SMALL-LIBRISPEECH-ASRは LibriSpeech ASRコーパス で学習されています。このデータセットは、約1000時間の16kHzの英語の読み上げ音声で構成されています。
学習手順
前処理
音声データは、PyKaldiまたはtorchaudioを介してWAV/FLACオーディオファイルから自動的にKaldi互換の80チャンネルのログメルフィルタバンク特徴量を抽出することで前処理されます。さらに、各サンプルに発話レベルのCMVN(ケプストラム平均と分散正規化)が適用されます。
テキストは小文字に変換され、SentencePieceを使用して語彙サイズ10,000でトークン化されます。
学習
モデルは、標準的な自己回帰的クロスエントロピー損失と SpecAugment を使用して学習されます。エンコーダは音声特徴量を受け取り、デコーダは自己回帰的に文字起こしを生成します。
BibTeXエントリと引用情報
@inproceedings{wang2020fairseqs2t,
title = {fairseq S2T: Fast Speech-to-Text Modeling with fairseq},
author = {Changhan Wang and Yun Tang and Xutai Ma and Anne Wu and Dmytro Okhonko and Juan Pino},
booktitle = {Proceedings of the 2020 Conference of the Asian Chapter of the Association for Computational Linguistics (AACL): System Demonstrations},
year = {2020},
}
📄 ライセンス
このモデルはMITライセンスの下で公開されています。