SenseVoice:多语言语音理解大模型(ASR+情感+音频事件)部署指南
SenseVoice 是阿里达摩院 FunAudioLLM 团队开源的语音基础模型,集成语音识别(ASR)、语种识别(LID)、语音情感识别(SER)与音频事件检测(AED)。论文训练覆盖 40 万小时数据、50+ 语言,发布的 SenseVoiceSmall 检查点支持中英日韩粤五语言;非自回归端到端架构,同参数下推理速度比 Whisper-Small 快 5 倍、比 Whisper-Large 快 15 倍。
一、项目官方信息
| 项目 | 信息 |
|---|---|
| GitHub 仓库 | FunAudioLLM/SenseVoice |
| 官方主页 | funasr.com |
| 开源协议 | MIT |
| 主要语言 | Python |
| Star 数 | 9.6k+ |
| 论文 | arXiv:2407.04051 |
| 检查点 | SenseVoiceSmall(234M) |
二、官方图片
SenseVoice 仓库社交预览图:

三、环境要求
- Python ≥ 3.8;
funasr>=1.3.26(推荐funasr==1.4.14);- PyTorch + torchaudio;
- 支持 CPU / GPU 推理,SenseVoiceSmall 仅 234M 参数,CPU 即可实时;
- 长音频需先经 FSMN-VAD 切片;
- ONNX / Libtorch 导出可选。
四、部署步骤
1. 安装
pip install -r requirements.txt
pip install -U "funasr>=1.3.26"
2. 基础推理
from funasr import AutoModel
from funasr.utils.postprocess_utils import rich_transcription_postprocess
model = AutoModel(
model="iic/SenseVoiceSmall",
trust_remote_code=True,
remote_code="./model.py",
vad_model="fsmn-vad",
vad_kwargs={"max_single_segment_time": 30000},
device="cuda:0",
)
res = model.generate(
input="asr_example_zh.wav",
cache={},
language="auto", # "zh", "en", "yue", "ja", "ko", "nospeech"
use_itn=True,
batch_size_s=60,
merge_vad=True,
merge_length_s=15,
)
text = rich_transcription_postprocess(res[0]["text"])
print(text)
关键参数
model_dir:模型名或本地路径;trust_remote_code=True:从remote_code指定的model.py加载模型实现;vad_model="fsmn-vad":开启 VAD,把长音频切成短片段;vad_kwargs={"max_single_segment_time": 30000}:单段最长 30 秒;use_itn=True:输出含标点与逆文本归一化;batch_size_s=60:按总时长 60 秒动态 batch;merge_vad=True:合并 VAD 切出的短片段;ban_emo_unk:是否禁用emo_unk情感标签。
3. 说话人分离(组合 FSMN-VAD + CAM++ + 标点)
from funasr import AutoModel
from funasr.utils.postprocess_utils import rich_transcription_postprocess
model = AutoModel(
model="iic/SenseVoiceSmall",
trust_remote_code=True,
remote_code="./model.py",
vad_model="fsmn-vad",
vad_kwargs={"max_single_segment_time": 30000},
spk_model="cam++",
punc_model="ct-punc",
device="cuda:0",
)
res = model.generate(input="example.wav", cache={}, language="auto",
use_itn=True, batch_size_s=60, merge_vad=True, merge_length_s=15)
for sent in res[0]["sentence_info"]:
text = rich_transcription_postprocess(sent["text"])
print(f"Speaker {sent['spk']}: [{sent['start']}ms - {sent['end']}ms] {text}")
4. 长音频无 VAD 处理
python long_audio_no_vad.py meeting.mp3 \
--output meeting.txt \
--window-seconds 30 \
--overlap-seconds 2
脚本用 ffmpeg 解码,按 30 秒窗口、2 秒重叠处理小时级录音,不配置 VAD 模型,避免编码器 OOM。
5. 直接调用模型(不经 FunASR)
from model import SenseVoiceSmall
from funasr.utils.postprocess_utils import rich_transcription_postprocess
m, kwargs = SenseVoiceSmall.from_pretrained(model="iic/SenseVoiceSmall", device="cuda:0")
m.eval()
res = m.inference(data_in="example/en.mp3", language="auto", use_itn=False, **kwargs)
print(rich_transcription_postprocess(res[0][0]["text"]))
6. ONNX 导出
pip3 install -U funasr funasr-onnx
from funasr_onnx import SenseVoiceSmall
model = SenseVoiceSmall("iic/SenseVoiceSmall", batch_size=10, quantize=True)
res = model(["example/en.mp3"], language="auto", use_itn=True)
7. 边缘部署(llama.cpp/GGUF)
bash runtime/llama.cpp/download-funasr-model.sh sensevoice ./gguf
llama-funasr-sensevoice -m ./gguf/sensevoice-small-f16.gguf --vad ./gguf/fsmn-vad.gguf -a audio.wav
五、使用方法
输出标签
识别文本自带情感标签与事件标签,如 <|HAPPY|>、<|SAD|>、<|BGM|>、<|APPLAUSE|>、<|LAUGHTER|>、<|CRYING|>、<|COUGHING|>、<|SNEEZE|>,通过 rich_transcription_postprocess 清理后可读。
能力范围
- ASR:中英日韩粤五语言;中文/粤语识别优于 Whisper;
- SER:情感识别零样本即可达到或超过专门 SER 模型;
- AED:检测 bgm、掌声、笑声、哭声、咳嗽、喷嚏等常见人机交互事件;
- 微调:仓库提供 finetune 脚本,可针对长尾业务场景微调。
服务部署
仓库提供多客户端(Python/C++/HTML/Java/C#)SDK,支持多并发请求,可作为企业语音后端服务。
六、常见问题 FAQ
Q1:SenseVoice 和 FunASR 什么关系?
SenseVoice 是模型,FunASR 是调用它的工具包;用 funasr 的 AutoModel 加载即可。
Q2:支持哪些语言? 发布的 SenseVoiceSmall 支持中英日韩粤;论文训练覆盖 50+ 语言。
Q3:怎么识别情感?
输出文本自带 <|HAPPY|> 等标签,后处理函数会保留这些标记。
Q4:CPU 能跑吗? 能,234M 参数非自回归模型,CPU 实时性很好。
Q5:长音频怎么处理?
先用 fsmn-vad 切片,或用 long_audio_no_vad.py 窗口化处理。
Q6:trust_remote_code 有什么用?
True 时从仓库 model.py 加载最新模型代码;False 时用 FunASR 内置版本。
Q7:支持 ONNX 导出吗?
支持,funasr-onnx 包导出后可在边缘 CPU 推理。
七、跳转链接
- GitHub 仓库:FunAudioLLM/SenseVoice
- ModelScope 模型:iic/SenseVoiceSmall
- Hugging Face:FunAudioLLM/SenseVoiceSmall
- GGUF 权重:FunAudioLLM/SenseVoiceSmall-GGUF
- 论文:arXiv:2407.04051