下面两种方法有什么区别,为什么我第一个报错,第二个可以
1
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
inference_pipeline = pipeline(
task=Tasks.auto_speech_recognition,
model='iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch',
model_revision="v2.0.4")
rec_result = inference_pipeline('https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_vad_punc_example.wav')
print(rec_result)
2
from funasr import AutoModel
model = AutoModel(model="paraformer-zh", model_revision="v2.0.4",
vad_model="fsmn-vad", vad_model_revision="v2.0.4",
punc_model="ct-punc-c", punc_model_revision="v2.0.4",
# spk_model="cam++", spk_model_revision="v2.0.2",
)
res = model.generate(input=f"{model.model_path}/example/asr_example.wav",
batch_size_s=300,
hotword='魔搭')
print(res)
第一种方法错误信息如下:
C:>python D:\python3\url.py
2024-02-04 14:37:40,405 - modelscope - INFO - PyTorch version 2.2.0 Found.
2024-02-04 14:37:40,415 - modelscope - INFO - Loading ast index from C:\Users\man.cache\modelscope\ast_indexer
2024-02-04 14:37:40,698 - modelscope - INFO - Loading done! Current index file version is 1.11.1, with md5 86717728ed73cdfdb006bab07ba66d92 and a total number of 956 components indexed
2024-02-04 14:37:43,685 - modelscope - INFO - Use user-specified model revision: v2.0.4
2024-02-04 14:37:44,070 - modelscope - INFO - initiate model from C:\Users\man.cache\modelscope\hub\iic\speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch
2024-02-04 14:37:44,070 - modelscope - INFO - initiate model from location C:\Users\man.cache\modelscope\hub\iic\speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch.
2024-02-04 14:37:44,070 - modelscope - INFO - initialize model from C:\Users\man.cache\modelscope\hub\iic\speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch
2024-02-04 14:37:52,524 - modelscope - WARNING - Model revision not specified, use revision: v2.0.0
Traceback (most recent call last):
File "D:\Python38\lib\site-packages\modelscope\utils\registry.py", line 210, in build_from_cfg
return obj_cls._instantiate(args)
File "D:\Python38\lib\site-packages\modelscope\models\base\base_model.py", line 67, in _instantiate
return cls(kwargs)
File "D:\Python38\lib\site-packages\modelscope\models\audio\funasr\model.py", line 55, in init
self.model = AutoModel(model=model_dir, kwargs)
File "D:\Python38\lib\site-packages\funasr\auto\auto_model.py", line 102, in init
vad_model, vad_kwargs = self.build_model(vad_kwargs)
File "D:\Python38\lib\site-packages\funasr\auto\auto_model.py", line 176, in build_model
model = model_class(kwargs, kwargs["model_conf"], vocab_size=vocab_size)
TypeError: 'NoneType' object is not callable