csukuangfj commited on
Commit
adcf3f3
·
verified ·
1 Parent(s): 5c7ee62

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +191 -0
README.md ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ # Highlights
6
+ **SenseVoice**专注于高精度多语言语音识别、情感辨识和音频事件检测
7
+ - **多语言识别:** 采用超过40万小时数据训练,支持超过50种语言,识别效果上优于Whisper模型。
8
+ - **富文本识别:**
9
+ - 具备优秀的情感识别,能够在测试数据上达到和超过目前最佳情感识别模型的效果。
10
+ - 支持声音事件检测能力,支持音乐、掌声、笑声、哭声、咳嗽、喷嚏等多种常见人机交互事件进行检测。
11
+ - **高效推理:** SenseVoice-Small模型采用非自回归端到端框架,推理延迟极低,10s音频推理仅耗时70ms,15倍优于Whisper-Large。
12
+ - **微调定制:** 具备便捷的微调脚本与策略,方便用户根据业务场景修复长尾样本问题。
13
+ - **服务部署:** 具有完整的服务部署链路,支持多并发请求,支持客户端语言有,python、c++、html、java与c#等。
14
+
15
+
16
+ ## <strong>[SenseVoice开源项目介绍](https://github.com/FunAudioLLM/SenseVoice)</strong>
17
+ <strong>[SenseVoice](https://github.com/FunAudioLLM/SenseVoice)</strong>开源模型是多语言音频理解模型,具有包括语音识别、语种识别、语音情感识别,声学事件检测能力。
18
+
19
+ [**github仓库**](https://github.com/FunAudioLLM/SenseVoice)
20
+ | [**最新动态**](https://github.com/FunAudioLLM/SenseVoice/blob/main/README_zh.md#%E6%9C%80%E6%96%B0%E5%8A%A8%E6%80%81)
21
+ | [**环境安装**](https://github.com/FunAudioLLM/SenseVoice/blob/main/README_zh.md#%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85)
22
+
23
+ # 模型结构图
24
+ SenseVoice多语言音频理解模型,支持语音识别、语种识别、语音情感识别、声学事件检测、逆文本正则化等能力,采用工业级数十万小时的标注音频进行模型训练,保证了模型的通用识别效果。模型可以被应用于中文、粤语、英语、日语、韩语音频识别,并输出带有情感和事件的富文本转写结果。
25
+
26
+ <p align="center">
27
+ <img src="fig/sensevoice.png" alt="SenseVoice模型结构" width="1500" />
28
+ </p>
29
+
30
+ SenseVoice-Small是基于非自回归端到端框架模型,为了指定任务,我们在语音特征前添加四个嵌入作为输入传递给编码器:
31
+ - LID:用于预测音频语种标签。
32
+ - SER:用于预测音频情感标签。
33
+ - AED:用于预测音频包含的事件标签。
34
+ - ITN:用于指定识别输出文本是否进行逆文本正则化。
35
+
36
+
37
+ # 依赖环境
38
+
39
+ 推理之前,请务必更新funasr与modelscope版本
40
+
41
+ ```shell
42
+ pip install -U funasr modelscope
43
+ ```
44
+
45
+ # 用法
46
+
47
+
48
+ ## 推理
49
+
50
+ ### modelscope pipeline推理
51
+ ```python
52
+ from modelscope.pipelines import pipeline
53
+ from modelscope.utils.constant import Tasks
54
+
55
+ inference_pipeline = pipeline(
56
+ task=Tasks.auto_speech_recognition,
57
+ model='iic/SenseVoiceSmall',
58
+ model_revision="master",
59
+ device="cuda:0",)
60
+
61
+ rec_result = inference_pipeline('https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav')
62
+ print(rec_result)
63
+ ```
64
+
65
+ ### 使用funasr推理
66
+
67
+ 支持任意格式音频输入,支持任意时长输入
68
+
69
+ ```python
70
+ from funasr import AutoModel
71
+ from funasr.utils.postprocess_utils import rich_transcription_postprocess
72
+
73
+ model_dir = "iic/SenseVoiceSmall"
74
+
75
+
76
+ model = AutoModel(
77
+ model=model_dir,
78
+ trust_remote_code=True,
79
+ remote_code="./model.py",
80
+ vad_model="fsmn-vad",
81
+ vad_kwargs={"max_single_segment_time": 30000},
82
+ device="cuda:0",
83
+ )
84
+
85
+ # en
86
+ res = model.generate(
87
+ input=f"{model.model_path}/example/en.mp3",
88
+ cache={},
89
+ language="auto", # "zn", "en", "yue", "ja", "ko", "nospeech"
90
+ use_itn=True,
91
+ batch_size_s=60,
92
+ merge_vad=True, #
93
+ merge_length_s=15,
94
+ )
95
+ text = rich_transcription_postprocess(res[0]["text"])
96
+ print(text)
97
+ ```
98
+ 参数说明:
99
+ - `model_dir`:模型名称,或本地磁盘中的模型路径。
100
+ - `trust_remote_code`:
101
+ - `True`表示model代码实现从`remote_code`处加载,`remote_code`指定`model`具体代码的位置(例如,当前目录下的`model.py`),支持绝对路径与相对路径,以及网络url。
102
+ - `False`表示,model代码实现为 [FunASR](https://github.com/modelscope/FunASR) 内部集成版本,此时修改当前目录下的`model.py`不会生效,因为加载的是funasr内部版本,模型代码[点击查看](https://github.com/modelscope/FunASR/tree/main/funasr/models/sense_voice)。
103
+ - `vad_model`:表示开启VAD,VAD的作用是将长音频切割成短音频,此时推理耗时包括了VAD与SenseVoice总耗时,为链路耗时,如果需要单独测试SenseVoice模型耗时,可以关闭VAD模型。
104
+ - `vad_kwargs`:表示VAD模型配置,`max_single_segment_time`: 表示`vad_model`最大切割音频时长, 单位是毫秒ms。
105
+ - `use_itn`:输出结果中是否包含标点与逆文本正则化。
106
+ - `batch_size_s` 表示采用动态batch,batch中总音频时长,单位为秒s。
107
+ - `merge_vad`:是否将 vad 模型切割的短音频碎片合成,���并后长度为`merge_length_s`,单位为秒s。
108
+ - `ban_emo_unk`:禁用emo_unk标签,禁用后所有的句子都会被赋与情感标签。默认`False`
109
+
110
+ ```python
111
+ model = AutoModel(model=model_dir, trust_remote_code=True, device="cuda:0")
112
+
113
+ res = model.generate(
114
+ input=f"{model.model_path}/example/en.mp3",
115
+ cache={},
116
+ language="auto", # "zn", "en", "yue", "ja", "ko", "nospeech"
117
+ use_itn=True,
118
+ batch_size=64,
119
+ )
120
+ ```
121
+
122
+ 更多详细用法,请参考 [文档](https://github.com/modelscope/FunASR/blob/main/docs/tutorial/README.md)
123
+
124
+
125
+
126
+ ## 模型下载
127
+ 上面代码会自动下载模型,如果您需要离线下载好模型,可以通过下面代码,手动下载,之后指定模型本地路径即可。
128
+
129
+ SDK下载
130
+ ```bash
131
+ #安装ModelScope
132
+ pip install modelscope
133
+ ```
134
+ ```python
135
+ #SDK模型下载
136
+ from modelscope import snapshot_download
137
+ model_dir = snapshot_download('iic/SenseVoiceSmall')
138
+ ```
139
+ Git下载
140
+ ```
141
+ #Git模型下载
142
+ git clone https://www.modelscope.cn/iic/SenseVoiceSmall.git
143
+ ```
144
+
145
+ ## 服务部署
146
+
147
+ Undo
148
+
149
+ # Performance
150
+
151
+ ## 语音识别效果
152
+ 我们在开源基准数据集(包括 AISHELL-1、AISHELL-2、Wenetspeech、Librispeech和Common Voice)上比较了SenseVoice与Whisper的多语言语音识别性能和推理效率。在中文和粤语识别效果上,SenseVoice-Small模型具有明显的效果优势。
153
+
154
+ <p align="center">
155
+ <img src="fig/asr_results.png" alt="SenseVoice模型在开源测试集上的表现" width="2500" />
156
+ </p>
157
+
158
+
159
+
160
+ ## 情感识别效果
161
+ 由于目前缺乏被广泛使用的情感识别测试指标和方法,我们在多个测试集的多种指标进行测试,并与近年来Benchmark上的多个结果进行了全面的对比。所选取的测试集同时包含中文/英文两种语言以及表演、影视剧、自然对话等多种风格的数据,在不进行目标数据微调的前提下,SenseVoice能够在测试数据上达到和超过目前最佳情感识别模型的效果。
162
+
163
+ <p align="center">
164
+ <img src="fig/ser_table.png" alt="SenseVoice模型SER效果1" width="1500" />
165
+ </p>
166
+
167
+ 同时,我们还在测试集上对多个开源情感识别模型进行对比,结果表明,SenseVoice-Large模型可以在几乎所有数据上都达到了最佳效果,而SenseVoice-Small模型同样可以在多数数据集上取得超越其他开源模型的效果。
168
+
169
+ <p align="center">
170
+ <img src="fig/ser_figure.png" alt="SenseVoice模型SER效果2" width="500" />
171
+ </p>
172
+
173
+ ## 事件检测效果
174
+
175
+ 尽管SenseVoice只在语音数据上进行训练,它仍然可以作为事件检测模型进行单独使用。我们在环境音分类ESC-50数据集上与目前业内广泛使用的BEATS与PANN模型的效果进行了对比。SenseVoice模型能够在这些任务上取得较好的效果,但受限于训练数据与训练方式,其事件分类效果专业的事件检测模型相比仍然有一定的差距。
176
+
177
+ <p align="center">
178
+ <img src="fig/aed_figure.png" alt="SenseVoice模型AED效果" width="500" />
179
+ </p>
180
+
181
+
182
+
183
+ ## 推理效率
184
+ SenseVoice-Small模型采用非自回归端到端架构,推理延迟极低。在参数量与Whisper-Small模型相当的情况下,比Whisper-Small模型推理速度快7倍,比Whisper-Large模型快17倍。同时SenseVoice-small模型在音频时长增加的情况下,推理耗时也无明显增加。
185
+
186
+
187
+ <p align="center">
188
+ <img src="fig/inference.png" alt="SenseVoice模型的推理效率" width="1500" />
189
+ </p>
190
+
191
+ <p style="color: lightgrey;">如果您是本模型的贡献者,我们邀请您根据<a href="https://modelscope.cn/docs/ModelScope%E6%A8%A1%E5%9E%8B%E6%8E%A5%E5%85%A5%E6%B5%81%E7%A8%8B%E6%A6%82%E8%A7%88" style="color: lightgrey; text-decoration: underline;">模型贡献文档</a>,及时完善模型卡片内容。</p>