"test/vscode:/vscode.git/clone" did not exist on "34150e616887dbd097fdc2156c0c110f266aeb4b"
Commit d71093e8 authored by wangwei990215's avatar wangwei990215
Browse files

Update README.md

parent 944725f2
......@@ -61,25 +61,27 @@ cd FunASR
pip3 install -e ./
```
### 推理
### 非实时语音识别/paraformer
### No-streaming 语音识别
```
from funasr import AutoModel
# paraformer-zh is a multi-functional asr model
# use vad, punc, spk or not as you need
model = AutoModel(
model=model_dir,
model="paraformer-zh",
vad_model="fsmn-vad",
punc_model="ct-punc")
res = model.generate(input=f"{model.model_path}/example/asr_example.wav",
batch_size_s=300,
hotword='魔搭')
res = model.generate(input="test_audio/asr_example_zh.wav")
print(res)
```
参数说明:
- model_dir:模型名称,或本地磁盘中的模型路径。
- vad_model:表示开启VAD,VAD的作用是将长音频切割成短音频,此时推理耗时包括了VAD与SenseVoice总耗时,为链路耗时,如果需要单独测试SenseVoice模型耗时,可以关闭VAD模型。
- vad_model:表示开启VAD,VAD的作用是将长音频切割成短音频,此时推理耗时包括了VAD与SenseVoice总耗时,为链路耗时,如果需要单独测试SenseVoice模型耗时,可以关闭VAD模型。<br>
- punc_model:针对输出文字的标点符号进行优化。<br>
### 实时语音识别
执行效果图:
![no-streaming 结果](images/resault_no_streaming.png)
### Streaming 语音识别
```
from funasr import AutoModel
......@@ -92,7 +94,7 @@ model = AutoModel(model="paraformer-zh-streaming")
import soundfile
import os
wav_file = os.path.join(model.model_path, "example/asr_example.wav")
wav_file = os.path.join(model.model_path, "test_audio/asr_example_zh.wav")
speech, sample_rate = soundfile.read(wav_file)
chunk_stride = chunk_size[1] * 960 # 600ms
......@@ -104,8 +106,16 @@ for i in range(total_chunk_num):
res = model.generate(input=speech_chunk, cache=cache, is_final=is_final, chunk_size=chunk_size, encoder_chunk_look_back=encoder_chunk_look_back, decoder_chunk_look_back=decoder_chunk_look_back)
print(res)
```
注:chunk_size为流式延时配置,[0,10,5]表示上屏实时出字粒度为10*60=600ms,未来信息为5*60=300ms。每次推理输入为600ms(采样点数为16000*0.6=960),输出为对应文字,最后一个语音片段输入需要设置is_final=True来强制输出最后一个字。
注:chunk_size为流式延时配置,[0,10,5]表示上屏实时出字粒度为10*60=600ms,未来信息为5*60=300ms。每次推理输入为600ms(采样点数为16000*0.6=960),输出为对应文字,最后一个语音片段输入需要设置is_final=True来强制输出最后一个字。<br>
执行效果图:
![streaming结果](images/resault_streaming.png)
上述streaming和no-streaming推理所用到的模型可从以下网址下载:
- paraformer-zh:https://hf-mirror.com/funasr/paraformer-zh
- paraformer-zh-streaming:https://hf-mirror.com/funasr/paraformer-zh-streaming
- fsmn-vad:https://hf-mirror.com/funasr/fsmn-vad
- ct-punc:https://hf-mirror.com/funasr/ct-punc
## 应用场景
### 算法分类
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment