🚀 用於AISHELL(普通話)的Transformer模型
本倉庫提供了在SpeechBrain中使用基於AISHELL(普通話)預訓練的端到端系統進行自動語音識別所需的所有工具。為了獲得更好的使用體驗,建議您進一步瞭解SpeechBrain。
該模型的性能如下:
發佈日期 |
開發集字符錯誤率(CER) |
測試集字符錯誤率(CER) |
GPU配置 |
完整結果 |
2021年3月5日 |
5.60 |
6.04 |
2xV100 32GB |
谷歌雲端硬盤 |
🚀 快速開始
本ASR系統由兩個不同但相互關聯的模塊組成:
- 分詞器(unigram):將單詞轉換為子詞單元,並使用LibriSpeech的訓練轉錄數據進行訓練。
- 聲學模型:由Transformer編碼器和帶有CTC + Transformer的聯合解碼器組成。因此,解碼過程也會納入CTC概率。
若要從頭開始訓練該系統,請查看我們的SpeechBrain配方。
該系統使用採樣率為16kHz(單聲道)的錄音進行訓練。調用transcribe_file時,代碼會根據需要自動對音頻進行歸一化處理(即重採樣和選擇單聲道)。
📦 安裝指南
首先,請使用以下命令安裝SpeechBrain:
pip install speechbrain
建議您閱讀我們的教程,進一步瞭解SpeechBrain。
💻 使用示例
基礎用法
對您自己的音頻文件(普通話)進行轉錄:
from speechbrain.inference.ASR import EncoderDecoderASR
asr_model = EncoderDecoderASR.from_hparams(source="speechbrain/asr-transformer-aishell", savedir="pretrained_models/asr-transformer-aishell")
asr_model.transcribe_file("speechbrain/asr-transformer-aishell/example_mandarin2.flac")
高級用法
在GPU上進行推理
若要在GPU上進行推理,調用from_hparams
方法時添加 run_opts={"device":"cuda"}
:
from speechbrain.inference.ASR import EncoderDecoderASR
asr_model = EncoderDecoderASR.from_hparams(source="speechbrain/asr-transformer-aishell", savedir="pretrained_models/asr-transformer-aishell", run_opts={"device":"cuda"})
asr_model.transcribe_file("speechbrain/asr-transformer-aishell/example_mandarin2.flac")
批量並行推理
若要了解如何使用預訓練模型對一批輸入語句進行並行轉錄,請查看此Colab筆記本。
模型訓練
該模型使用SpeechBrain進行訓練(提交哈希值:'986a2175')。若要從頭開始訓練,請按照以下步驟操作:
- 克隆SpeechBrain倉庫:
git clone https://github.com/speechbrain/speechbrain/
- 安裝依賴:
cd speechbrain
pip install -r requirements.txt
pip install -e .
- 運行訓練腳本:
cd recipes/AISHELL-1/ASR/transformer/
python train.py hparams/train_ASR_transformer.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許可證。