🚀 基於xvector嵌入在Google語音命令數據集上進行命令識別
本項目提供了使用預訓練於Google語音命令數據集的模型,藉助SpeechBrain執行命令識別所需的全部工具。你可以在此下載該數據集。此數據集提供了小型的訓練集、驗證集和測試集,可用於在短音頻片段中檢測單個關鍵詞。本系統能夠識別以下12個關鍵詞:
'yes', 'no', 'up', 'down', 'left', 'right', 'on', 'off', 'stop', 'go', 'unknown', 'silence'
為獲得更好的使用體驗,我們建議你進一步瞭解SpeechBrain。該模型在測試集上的性能表現如下:
版本 |
準確率(%) |
06 - 02 - 21 |
98.14 |
🚀 快速開始
本項目提供了使用預訓練於Google語音命令數據集的模型,藉助SpeechBrain執行命令識別所需的全部工具。你可以在此下載該數據集。
✨ 主要特性
- 能夠識別12個常見關鍵詞,包括 'yes', 'no', 'up' 等。
- 模型在測試集上達到了98.14%的準確率。
- 代碼會自動對音頻進行歸一化處理(重採樣 + 單聲道選擇)。
📦 安裝指南
首先,請使用以下命令安裝SpeechBrain:
pip install speechbrain
建議你閱讀相關教程,進一步瞭解SpeechBrain。
💻 使用示例
基礎用法
import torchaudio
from speechbrain.inference.classifiers import EncoderClassifier
classifier = EncoderClassifier.from_hparams(source="speechbrain/google_speech_command_xvector", savedir="pretrained_models/google_speech_command_xvector")
out_prob, score, index, text_lab = classifier.classify_file('speechbrain/google_speech_command_xvector/yes.wav')
print(text_lab)
out_prob, score, index, text_lab = classifier.classify_file('speechbrain/google_speech_command_xvector/stop.wav')
print(text_lab)
高級用法
在GPU上進行推理
若要在GPU上進行推理,在調用 from_hparams
方法時添加 run_opts={"device":"cuda"}
。
📚 詳細文檔
管道描述
本系統由一個與統計池化相結合的TDNN模型組成。在此基礎上應用了一個使用分類交叉熵損失訓練的分類器。
系統使用採樣率為16kHz(單聲道)的錄音進行訓練。調用 classify_file 時,代碼會根據需要自動對音頻進行歸一化處理(即重採樣 + 單聲道選擇)。
訓練步驟
若要從頭開始訓練模型,請遵循以下步驟:
- 克隆SpeechBrain倉庫:
git clone https://github.com/speechbrain/speechbrain/
- 安裝依賴:
cd speechbrain
pip install -r requirements.txt
pip install -e .
- 運行訓練腳本:
cd recipes/Google-speech-commands
python train.py hparams/xvect.yaml --data_folder=your_data_folder
你可以在此找到訓練結果(模型、日誌等)。
侷限性
SpeechBrain團隊不保證該模型在其他數據集上的性能表現。
引用說明
引用xvectors
author = {David Snyder and
Daniel Garcia{-}Romero and
Alan McCree and
Gregory Sell and
Daniel Povey and
Sanjeev Khudanpur},
title = {Spoken Language Recognition using X-vectors},
booktitle = {Odyssey 2018},
pages = {105--111},
year = {2018},
}
引用Google語音命令數據集
author = { {Warden}, P.},
title = "{Speech Commands: A Dataset for Limited-Vocabulary Speech Recognition}",
journal = {ArXiv e-prints},
archivePrefix = "arXiv",
eprint = {1804.03209},
primaryClass = "cs.CL",
keywords = {Computer Science - Computation and Language, Computer Science - Human-Computer Interaction},
year = 2018,
month = apr,
url = {https://arxiv.org/abs/1804.03209},
}
📄 許可證
本項目採用Apache 2.0許可證。
關於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}
}