🚀 基于 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 团队不对该模型在其他数据集上的性能提供任何保证。