🚀 大声(Dasheng):大规模通用音频编码器
大声(Dasheng,Deep Audio-Signal Holistic Embeddings),或“大声”(中文意为“响亮的声音”),是一个在大规模自监督学习任务上训练的通用音频编码器。大声旨在捕捉包括语音、音乐和环境声音等各个领域的丰富音频信息。该模型在272,356小时的多样化音频数据上进行训练,拥有12亿个参数,并在HEAR基准测试中展现出显著的性能提升。在CREMA - D、LibriCount、语音命令、VoxLingua等任务上,大声超越了以往的工作成果,并且在音乐和环境声音分类任务中也表现出色。
原始仓库地址:https://github.com/XiaoMi/dasheng

🚀 快速开始
✨ 主要特性
- 通用音频编码:能够处理多种类型的音频,包括语音、音乐和环境声音。
- 大规模训练:在272,356小时的多样化音频数据上训练,拥有12亿个参数。
- 性能优越:在HEAR基准测试和多个音频分类任务中表现出色。
📦 安装指南
pip install git+https://github.com/jimbozhang/hf_transformers_custom_model_dasheng.git
💻 使用示例
基础用法
>>> model_name = "mispeech/dasheng-1.2B"
>>> from dasheng_model.feature_extraction_dasheng import DashengFeatureExtractor
>>> from dasheng_model.modeling_dasheng import DashengModel
>>> feature_extractor = DashengFeatureExtractor.from_pretrained(model_name)
>>> model = DashengModel.from_pretrained(model_name, outputdim=None)
>>> import torchaudio
>>> audio, sampling_rate = torchaudio.load("resources/JeD5V5aaaoI_931_932.wav")
>>> assert sampling_rate == 16000
>>> audio.shape
torch.Size([1, 16000])
>>> inputs = feature_extractor(audio, sampling_rate=sampling_rate, return_tensors="pt")
>>> inputs.input_values.shape
torch.Size([1, 64, 101])
>>> import torch
>>> with torch.no_grad():
... outputs = model(**inputs)
>>> outputs.hidden_states.shape
torch.Size([1, 25, 768])
>>> outputs.logits.shape
torch.Size([1, 768])
高级用法
在ESC - 50数据集上微调模型:
点击下面的链接在Colab中打开示例代码:

具体代码可参考:example_finetune_esc50.ipynb
,该示例展示了如何在冻结大声编码器的情况下,在ESC - 50数据集上训练一个线性头部。
📄 许可证
本项目采用Apache - 2.0许可证。
📚 详细文档
如果您在研究中发现大声模型很有用,请引用以下论文:
@inproceedings{dinkel2023scaling,
title={Scaling up masked audio encoder learning for general audio classification},
author={Dinkel, Heinrich and Yan, Zhiyong and Wang, Yongqing and Zhang, Junbo and Wang, Yujun and Wang, Bin},
booktitle={Interspeech 2024},
year={2024}
}