From 3318d07470d3f91e55ca0f02c77536a7c514efb1 Mon Sep 17 00:00:00 2001 From: speech_asr Date: Tue, 23 Jul 2024 10:46:20 +0000 Subject: [PATCH] Update README.md --- README.md | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 233565a..2ab92da 100644 --- a/README.md +++ b/README.md @@ -125,13 +125,15 @@ print(text) ``` 参数说明: - `model_dir`:模型名称,或本地磁盘中的模型路径。 +- `trust_remote_code`: + - `True`表示model代码实现从`remote_code`处加载,`remote_code`指定`model`具体代码的位置(例如,当前目录下的`model.py`),支持绝对路径与相对路径,以及网络url。 + - `False`表示,model代码实现为 [FunASR](https://github.com/modelscope/FunASR) 内部集成版本,此时修改当前目录下的`model.py`不会生效,因为加载的是funasr内部版本,模型代码[点击查看](https://github.com/modelscope/FunASR/tree/main/funasr/models/sense_voice)。 - `vad_model`:表示开启VAD,VAD的作用是将长音频切割成短音频,此时推理耗时包括了VAD与SenseVoice总耗时,为链路耗时,如果需要单独测试SenseVoice模型耗时,可以关闭VAD模型。 - `vad_kwargs`:表示VAD模型配置,`max_single_segment_time`: 表示`vad_model`最大切割音频时长, 单位是毫秒ms。 - `use_itn`:输出结果中是否包含标点与逆文本正则化。 - `batch_size_s` 表示采用动态batch,batch中总音频时长,单位为秒s。 - `merge_vad`:是否将 vad 模型切割的短音频碎片合成,合并后长度为`merge_length_s`,单位为秒s。 - -如果输入均为短音频(小于30s),并且需要批量化推理,为了加快推理效率,可以移除vad模型,并设置`batch_size` +- `ban_emo_unk`:禁用emo_unk标签,禁用后所有的句子都会被赋与情感标签。默认`False` ```python model = AutoModel(model=model_dir, trust_remote_code=True, device="cuda:0") @@ -147,28 +149,7 @@ res = model.generate( 更多详细用法,请参考 [文档](https://github.com/modelscope/FunASR/blob/main/docs/tutorial/README.md) -### 直接推理 -支持任意格式音频输入,输入音频时长限制在30s以下 - -```python -from model import SenseVoiceSmall -from funasr.utils.postprocess_utils import rich_transcription_postprocess - -model_dir = "iic/SenseVoiceSmall" -m, kwargs = SenseVoiceSmall.from_pretrained(model=model_dir, device="cuda:0") - - -res = m.inference( - data_in=f"{kwargs['model_path']}/example/en.mp3", - language="auto", # "zn", "en", "yue", "ja", "ko", "nospeech" - use_itn=False, - **kwargs, -) - -text = rich_transcription_postprocess(res[0][0]["text"]) -print(text) -``` ## 模型下载 上面代码会自动下载模型,如果您需要离线下载好模型,可以通过下面代码,手动下载,之后指定模型本地路径即可。