🚀 CommonAccent:基於CommonVoice探索用於口音分類的大型聲學預訓練模型
使用XLSR模型的英語口音分類器
本項目旨在解決自動語音識別(ASR)中帶口音語音識別的難題,通過ECAPA - TDNN和Wav2Vec 2.0/XLSR架構進行多語言口音分類。利用SpeechBrain工具包,基於Common Voice數據集開展研究,在英語口音分類上取得了高達95%的準確率。
🚀 快速開始
本倉庫提供了使用 SpeechBrain 從語音記錄中進行口音識別的所有必要工具。系統使用了在CommonAccent英語數據集(16種口音)上預訓練的模型,基於位於此處的CommonLanguage配方:https://github.com/speechbrain/speechbrain/tree/develop/recipes/CommonLanguage 。
提供的系統可以從英語(EN)的短語音記錄中識別以下16種口音:
- us
- england
- australia
- indian
- canada
- bermuda
- scotland
- african
- ireland
- newzealand
- wales
- malaysia
- philippines
- singapore
- hongkong
- southatlandtic
Github倉庫鏈接:https://github.com/JuanPZuluaga/accent-recog-slt2022
⚠️ 重要提示
由於模型與當前SpeechBrain接口不兼容,我們無法提供推理API。請按照“從語音記錄中進行口音識別”中的步驟使用此意大利口音識別模型。
💡 使用建議
為了獲得更好的體驗,建議您進一步瞭解 SpeechBrain。
✨ 主要特性
- 多語言口音分類:通過ECAPA - TDNN和Wav2Vec 2.0/XLSR架構,實現多語言口音分類。
- 高準確率:在英語口音分類上達到了高達95%的準確率。
- 基於Common Voice數據集:使用Common Voice 7.0(英語)和Common Voice 11.0(意大利語、德語和西班牙語)進行訓練。
📦 安裝指南
安裝SpeechBrain
首先,請使用以下命令安裝SpeechBrain:
pip install speechbrain
建議您閱讀相關教程,進一步瞭解 SpeechBrain。
💻 使用示例
基礎用法
以下是從語音記錄中進行口音識別的示例代碼:
import torchaudio
from speechbrain.pretrained.interfaces import foreign_class
classifier = foreign_class(source="Jzuluaga/accent-id-commonaccent_xlsr-en-english", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
out_prob, score, index, text_lab = classifier.classify_file('Jzuluaga/accent-id-commonaccent_xlsr-en-english/data/us.wav')
print(text_lab)
out_prob, score, index, text_lab = classifier.classify_file('Jzuluaga/accent-id-commonaccent_xlsr-en-english/data/philippines.wav')
print(text_lab)
高級用法
在GPU上進行推理
若要在GPU上進行推理,在調用 from_hparams
方法時添加 run_opts={"device":"cuda"}
。
📚 詳細文檔
管道描述
該系統由一個微調的XLSR模型和統計池化組成,在此基礎上應用了一個使用NLL損失訓練的分類器。
系統使用採樣率為16kHz(單聲道)的錄音進行訓練。調用 classify_file 時,代碼會自動對音頻進行歸一化處理(即重採樣 + 單聲道選擇)。如果使用 encode_batch 和 classify_batch,請確保輸入張量符合預期的採樣率。
訓練
模型使用SpeechBrain進行訓練。若要從頭開始訓練,請按照以下步驟操作:
- 克隆SpeechBrain:
git clone https://github.com/speechbrain/speechbrain/
- 安裝:
cd speechbrain
pip install -r requirements.txt
pip install -e .
- 克隆我們的倉庫:
git clone https://github.com/JuanPZuluaga/accent-recog-slt2022
cd CommonAccent/accent_id
python train_w2v2.py hparams/train_w2v2.yaml
您可以在本倉庫的 文件和版本
頁面找到訓練結果(模型、日誌等)。
侷限性
SpeechBrain團隊不保證該模型在其他數據集上的性能。
🔧 技術細節
摘要
儘管自動語音識別(ASR)最近取得了進展,但帶口音語音的識別仍然是一個主要問題。為了創建更具包容性的ASR系統,研究表明,將口音信息作為更大ASR框架的一部分進行整合,可以減少帶口音語音的識別錯誤。我們通過ECAPA - TDNN和Wav2Vec 2.0/XLSR架構解決多語言口音分類問題,這些架構已被證明在各種與語音相關的下游任務中表現良好。我們介紹了一個簡單易懂的、與SpeechBrain工具包對齊的口音分類配方,該配方基於Common Voice 7.0(英語)和Common Voice 11.0(意大利語、德語和西班牙語)。此外,我們在英語口音分類方面建立了新的技術水平,準確率高達95%。我們還通過t - SNE研究了Wav2Vev 2.0嵌入的內部分類,發現存在基於語音相似性的聚類現象。
📄 許可證
本項目採用MIT許可證。
📖 引用說明
引用本項目
如果您覺得本項目有用,請按以下方式引用:
@article{zuluaga2023commonaccent,
title={CommonAccent: Exploring Large Acoustic Pretrained Models for Accent Classification Based on Common Voice},
author={Zuluaga-Gomez, Juan and Ahmed, Sara and Visockas, Danielius and Subakan, Cem},
journal={Interspeech 2023},
url={https://arxiv.org/abs/2305.18283},
year={2023}
}
引用XLSR模型
@article{conneau2020unsupervised,
title={Unsupervised cross-lingual representation learning for speech recognition},
author={Conneau, Alexis and Baevski, Alexei and Collobert, Ronan and Mohamed, Abdelrahman and Auli, Michael},
journal={arXiv preprint arXiv:2006.13979},
year={2020}
}
引用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}
}