🚀 S2T-SMALL-LIBRISPEECH-ASR
s2t-small-librispeech-asr
は、自動音声認識(ASR)用に学習された音声からテキストへの変換トランスフォーマー(S2T)モデルです。S2Tモデルは この論文 で提案され、このリポジトリ で公開されています。
🚀 クイックスタート
このモデルは、エンドツーエンドの音声認識(ASR)に使用できます。他のS2Tチェックポイントを探すには、モデルハブ を参照してください。
✨ 主な機能
S2Tはエンドツーエンドのシーケンスツーシーケンストランスフォーマーモデルです。標準的な自己回帰的交差エントロピー損失を使用して学習され、自己回帰的に文字起こしを生成します。
📦 インストール
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_ids=input_features)
transcription = processor.batch_decode(generated_ids)
高度な使用法
LibriSpeechテストデータセットでの評価
from datasets import load_dataset, load_metric
from transformers import Speech2TextForConditionalGeneration, Speech2TextProcessor
librispeech_eval = load_dataset("librispeech_asr", "clean", split="test")
wer = load_metric("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)
librispeech_eval = librispeech_eval.map(map_to_array)
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_ids=input_features, attention_mask=attention_mask)
batch["transcription"] = processor.batch_decode(gen_tokens, skip_special_tokens=True)
return batch
result = librispeech_eval.map(map_to_pred, batched=True, batch_size=8, remove_columns=["speech"])
print("WER:", wer(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ライセンスの下で提供されています。