🚀 wav2vec 2.0 基於 CTC/Attention 在 CommonVoice 法語數據集上訓練(無語言模型)
本倉庫提供了在 SpeechBrain 中使用基於 CommonVoice(法語)預訓練的端到端系統進行自動語音識別所需的所有工具。為獲得更好的體驗,我們建議您進一步瞭解 SpeechBrain。
模型信息
屬性 |
詳情 |
模型類型 |
自動語音識別 |
標籤 |
CTC、pytorch、speechbrain、Transformer、hf - asr - leaderboard |
許可證 |
apache - 2.0 |
訓練數據集 |
commonvoice |
評估指標 |
wer、cer |
模型表現
發佈時間 |
測試字符錯誤率(CER) |
測試詞錯誤率(WER) |
GPU 配置 |
2021 年 8 月 24 日 |
3.19 |
9.96 |
2 塊 V100 32GB |
🚀 快速開始
本自動語音識別(ASR)系統由兩個不同但相互關聯的模塊組成:
- 分詞器(unigram):將單詞轉換為子詞單元,並使用 CommonVoice(法語)的訓練轉錄文件(train.tsv)進行訓練。
- 聲學模型(wav2vec2.0 + CTC):將預訓練的 wav2vec 2.0 模型([LeBenchmark/wav2vec2 - FR - 7K - large](https://huggingface.co/LeBenchmark/wav2vec2 - FR - 7K - large))與兩個深度神經網絡(DNN)層相結合,並在 CommonVoice 法語數據集上進行微調。最終得到的聲學表示將輸入到 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-commonvoice-fr", savedir="pretrained_models/asr-wav2vec2-commonvoice-fr")
asr_model.transcribe_file('speechbrain/asr-wav2vec2-commonvoice-fr/example-fr.wav')
高級用法
在 GPU 上進行推理:
在調用 from_hparams
方法時添加 run_opts={"device":"cuda"}
。
from speechbrain.inference.ASR import EncoderASR
asr_model = EncoderASR.from_hparams(source="speechbrain/asr-wav2vec2-commonvoice-fr", savedir="pretrained_models/asr-wav2vec2-commonvoice-fr", run_opts={"device":"cuda"})
asr_model.transcribe_file('speechbrain/asr-wav2vec2-commonvoice-fr/example-fr.wav')
🔧 技術細節
訓練步驟
該模型使用 SpeechBrain 進行訓練。若要從頭開始訓練,請按以下步驟操作:
- 克隆 SpeechBrain 倉庫:
git clone https://github.com/speechbrain/speechbrain/
- 安裝依賴:
cd speechbrain
pip install -r requirements.txt
pip install -e .
- 運行訓練腳本:
cd recipes/CommonVoice/ASR/CTC/
python train_with_wav2vec.py hparams/train_fr_with_wav2vec.yaml --data_folder=your_data_folder
您可以在 此處 找到我們的訓練結果(模型、日誌等)。
侷限性
SpeechBrain 團隊不對該模型在其他數據集上的性能提供任何保證。
📚 詳細文檔
引用 SpeechBrain
@misc{SB2021,
author = {Ravanelli, Mirco and Parcollet, Titouan and Rouhe, Aku and Plantinga, Peter and Rastorgueva, Elena and Lugosch, Loren and Dawalatabad, Nauman and Ju-Chieh, Chou and Heba, Abdel and Grondin, Francois and Aris, William and Liao, Chien-Feng and Cornell, Samuele and Yeh, Sung-Lin and Na, Hwidong and Gao, Yan and Fu, Szu-Wei and Subakan, Cem and De Mori, Renato and Bengio, Yoshua },
title = {SpeechBrain},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\\\\url{https://github.com/speechbrain/speechbrain}},
}
關於 SpeechBrain
SpeechBrain 是一個開源的一體化語音工具包。它設計簡單、極其靈活且用戶友好,在多個領域都取得了有競爭力或最先進的性能。
- 官網:https://speechbrain.github.io/
- GitHub:https://github.com/speechbrain/speechbrain
📄 許可證
本項目採用 apache - 2.0 許可證。