🚀 wav2vec 2.0 with CTC trained on LibriSpeech
本倉庫提供了在 SpeechBrain 中基於端到端系統對 LibriSpeech(英語)進行預訓練以執行自動語音識別所需的全部工具。為獲得更好的體驗,我們建議您進一步瞭解 SpeechBrain。
🚀 快速開始
本倉庫提供了在 SpeechBrain 中基於端到端系統對 LibriSpeech(英語)進行預訓練以執行自動語音識別所需的全部工具。為獲得更好的體驗,我們建議您進一步瞭解 SpeechBrain。
模型的性能如下:
版本發佈日期 |
測試集(乾淨數據)的字錯率(WER) |
測試集(其他數據)的字錯率(WER) |
所用 GPU |
2022 年 3 月 24 日 |
1.90 |
3.96 |
1 個 A100 40GB |
✨ 主要特性
此自動語音識別(ASR)系統由兩個不同但相互關聯的模塊組成:
- 分詞器(unigram):將單詞轉換為字符,並使用訓練轉錄數據(英語)進行訓練。
- 聲學模型(wav2vec2.0 + CTC):將預訓練的 wav2vec 2.0 模型(wav2vec2-large-960h-lv60-self)與兩個深度神經網絡(DNN)層相結合,並在 LibriSpeech 上進行微調。得到的最終聲學表示將輸入到 CTC 中。
該系統使用採樣率為 16kHz(單聲道)的錄音進行訓練。當調用 transcribe_file 時,如果需要,代碼將自動對音頻進行歸一化處理(即重採樣和單聲道選擇)。
📦 安裝指南
首先,請使用以下命令安裝 transformers
和 SpeechBrain
:
pip install speechbrain transformers
請注意,我們建議您閱讀我們的教程並進一步瞭解 SpeechBrain。
💻 使用示例
基礎用法
對您自己的音頻文件(英語)進行轉錄:
from speechbrain.inference.ASR import EncoderASR
asr_model = EncoderASR.from_hparams(source="speechbrain/asr-wav2vec2-librispeech", savedir="pretrained_models/asr-wav2vec2-librispeech")
asr_model.transcribe_file("speechbrain/asr-wav2vec2-commonvoice-en/example.wav")
高級用法
在 GPU 上進行推理
若要在 GPU 上進行推理,在調用 from_hparams
方法時添加 run_opts={"device":"cuda"}
:
from speechbrain.inference.ASR import EncoderASR
asr_model = EncoderASR.from_hparams(source="speechbrain/asr-wav2vec2-librispeech", savedir="pretrained_models/asr-wav2vec2-librispeech", run_opts={"device":"cuda"})
asr_model.transcribe_file("speechbrain/asr-wav2vec2-commonvoice-en/example.wav")
批量並行推理
請參考 此 Colab 筆記本,瞭解如何使用預訓練模型對一批輸入語句進行並行轉錄。
🔧 技術細節
訓練步驟
該模型使用 SpeechBrain 進行訓練。若要從頭開始訓練,請按照以下步驟操作:
- 克隆 SpeechBrain 倉庫:
git clone https://github.com/speechbrain/speechbrain/
- 安裝依賴:
cd speechbrain
pip install -r requirements.txt
pip install -e .
- 運行訓練腳本:
cd recipes/LibriSpeech/ASR/CTC
python train_with_wav2vec.py hparams/train_en_with_wav2vec.yaml --data_folder=your_data_folder
您可以在 此處 找到我們的訓練結果(模型、日誌等)。
侷限性
SpeechBrain 團隊不保證該模型在其他數據集上的性能。
📚 詳細文檔
關於 SpeechBrain
- 官網:https://speechbrain.github.io/
- 代碼倉庫:https://github.com/speechbrain/speechbrain/
- HuggingFace 頁面:https://huggingface.co/speechbrain/
引用 SpeechBrain
如果您在研究或業務中使用了 SpeechBrain,請引用以下文獻:
@misc{speechbrain,
title={{SpeechBrain}: A General-Purpose Speech Toolkit},
author={Mirco Ravanelli and Titouan Parcollet and Peter Plantinga and Aku Rouhe and Samuele Cornell and Loren Lugosch and Cem Subakan and Nauman Dawalatabad and Abdelwahab Heba and Jianyuan Zhong and Ju-Chieh Chou and Sung-Lin Yeh and Szu-Wei Fu and Chien-Feng Liao and Elena Rastorgueva and François Grondin and William Aris and Hwidong Na and Yan Gao and Renato De Mori and Yoshua Bengio},
year={2021},
eprint={2106.04624},
archivePrefix={arXiv},
primaryClass={eess.AS},
note={arXiv:2106.04624}
}
📄 許可證
本項目採用 Apache 2.0 許可證。
屬性 |
詳情 |
模型類型 |
基於 wav2vec 2.0 和 CTC 的自動語音識別模型 |
訓練數據 |
LibriSpeech(英語) |
評估指標 |
字錯率(WER)、字符錯誤率(CER) |