🚀 基於 IEMOCAP 的 wav2vec2 情感識別
本倉庫提供了使用 SpeechBrain 對微調後的 wav2vec2(基礎)模型進行情感識別所需的所有工具。該模型在 IEMOCAP 訓練數據上進行訓練。
為了獲得更好的體驗,我們建議您進一步瞭解 SpeechBrain。該模型在 IEMOCAP 測試集上的性能如下:
版本發佈日期 |
準確率(%) |
2021 年 10 月 19 日 |
78.7(平均:75.3) |
🚀 快速開始
安裝 SpeechBrain
首先,請使用以下命令安裝 SpeechBrain 的 開發 版本:
pip install git+https://github.com/speechbrain/speechbrain.git@develop
請注意,我們建議您閱讀我們的教程並進一步瞭解 SpeechBrain。
進行情感識別
外部 py_module_file=custom.py
作為外部預測器類用於此 HF 倉庫。我們使用 speechbrain.pretrained.interfaces
中的 foreign_class
函數來加載自定義模型。
from speechbrain.inference.interfaces import foreign_class
classifier = foreign_class(source="speechbrain/emotion-recognition-wav2vec2-IEMOCAP", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
out_prob, score, index, text_lab = classifier.classify_file("speechbrain/emotion-recognition-wav2vec2-IEMOCAP/anger.wav")
print(text_lab)
預測張量將包含一個元組 (embedding, id_class, label_name)。
在 GPU 上進行推理
要在 GPU 上進行推理,請在調用 from_hparams
方法時添加 run_opts={"device":"cuda"}
。
訓練
該模型使用 SpeechBrain (aa018540) 進行訓練。要從頭開始訓練,請按照以下步驟操作:
- 克隆 SpeechBrain:
git clone https://github.com/speechbrain/speechbrain/
- 安裝:
cd speechbrain
pip install -r requirements.txt
pip install -e .
- 運行訓練:
cd recipes/IEMOCAP/emotion_recognition
python train_with_wav2vec2.py hparams/train_with_wav2vec2.yaml --data_folder=your_data_folder
您可以在 這裡 找到我們的訓練結果(模型、日誌等)。
✨ 主要特性
管道描述
該系統由一個 wav2vec2 模型組成,它是卷積塊和殘差塊的組合。使用注意力統計池化提取嵌入。系統使用加性邊際軟最大損失進行訓練。說話人驗證使用說話人嵌入之間的餘弦距離進行。
該系統使用採樣率為 16kHz(單聲道)的錄音進行訓練。調用 classify_file 時,代碼將根據需要自動對音頻進行歸一化(即重採樣 + 單聲道選擇)。
📄 許可證
本項目採用 Apache-2.0 許可證。
📚 詳細文檔
引用 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}
}
關於 SpeechBrain
- 網站:https://speechbrain.github.io/
- 代碼:https://github.com/speechbrain/speechbrain/
- HuggingFace:https://huggingface.co/speechbrain/
侷限性
SpeechBrain 團隊不對該模型在其他數據集上的性能提供任何保證。