modelscope-funasr关于离线加载的问题,env:linux,python=3.9,torch=2.1.1,fuasr=0.8.4,modelscope=1.9.4。
docs:
questions:离线环境下未能加载本地的funasr的模型始终需要链接modelscope社区,然后一直处于等待请求状态请问这是为什么?
code和配置
code:
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
inference_pipeline = pipeline(task=Tasks.auto_speech_recognition,model='/data/model_from_modelscope/damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch',vad_model='/data/model_from_modelscope/damo/speech_fsmn_vad_zh-cn-16k-common-pytorch',punc_model='/data/model_from_modelscope/damo/punc_ct-transformer_cn-en-common-vocab471067-large')
import time
start_time = time.time()
wav_name = "./2023110200000949.wav"
rec_result = inference_pipeline(audio_in=wav_name)
end_time = time.time()
print("消耗时间",end_time-start_time)
模型配置文件如下
speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch/configuration.json修改各模型modelpath如下:
{
"framework": "pytorch",
"task" : "auto-speech-recognition",
"model" : {
"type" : "generic-asr",
"am_model_name" : "model.pb",
"model_config" : {
"type": "pytorch",
"code_base": "funasr",
"mode": "paraformer",
"lang": "zh-cn",
"batch_size": 1,
"am_model_config": "config.yaml",
"asr_model_config": "decoding.yaml",
"mvn_file": "am.mvn",
"model": "/data/model_from_modelscope/damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch",
"vad_model": "/data/model_from_modelscope/damo/speech_fsmn_vad_zh-cn-16k-common-pytorch",
"punc_model": "/data/model_from_modelscope/damo/punc_ct-transformer_zh-cn-common-vocab272727-pytorch"
}
},
"pipeline": {
"type":"asr-inference"
}
}
vad-modelpath的configuration.json配置:
{
"framework": "pytorch",
"task" : "voice-activity-detection",
"model" : {
"type" : "generic-asr",
"am_model_name": "vad.pb",
"model_config" : {
"type": "pytorch",
"code_base": "funasr",
"mode": "offline",
"lang": "zh-cn",
"batch_size": 1,
"vad_model_name": "vad.pb",
"vad_model_config": "vad.yaml",
"vad_mvn_file": "vad.mvn",
"model": "/data/model_from_modelscope/damo/speech_fsmn_vad_zh-cn-16k-common-pytorch"
}
},
"pipeline": {
"type":"vad-inference"
}
}
punc_ct-model的configuration.json配置:
{
"framework": "pytorch",
"task" : "punctuation",
"model" : {
"type" : "generic-punc",
"punc_model_name" : "punc.pb",
"punc_model_config" : {
"type": "pytorch",
"code_base": "funasr",
"mode": "punc",
"lang": "zh-cn",
"batch_size": 1,
"punc_config": "punc.yaml",
"model": "/data/model_from_modelscope/damo/punc_ct-transformer_zh-cn-common-vocab272727-pytorch"
}
},
"pipeline": {
"type":"punc-inference"
}
}
运行信息如下
2023-12-12 09:14:48,215 - modelscope - INFO - PyTorch version 2.1.1 Found.
2023-12-12 09:14:48,215 - modelscope - INFO - Loading ast index from /root/.cache/modelscope/ast_indexer
2023-12-12 09:14:48,298 - modelscope - INFO - Loading done! Current index file version is 1.9.4, with md5 9d02da553bf8b162382a09ae52dc0aef and a total number of 945 components indexed
2023-12-12 09:14:48,935 - modelscope - INFO - initiate model from /data/model_from_modelscope/damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch
2023-12-12 09:14:48,935 - modelscope - INFO - initiate model from location /data/model_from_modelscope/damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch.
2023-12-12 09:14:48,936 - modelscope - INFO - initialize model from /data/model_from_modelscope/damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch
2023-12-12 09:14:48,939 - modelscope - WARNING - No preprocessor field found in cfg.
2023-12-12 09:14:48,939 - modelscope - WARNING - No val key and type key found in preprocessor domain of configuration.json file.
2023-12-12 09:14:48,939 - modelscope - WARNING - Cannot find available config to build preprocessor at mode inference, current config: {'model_dir': '/data/model_from_modelscope/damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch'}. trying to build by task and model information.
2023-12-12 09:14:48,939 - modelscope - WARNING - No preprocessor key ('generic-asr', 'auto-speech-recognition') found in PREPROCESSOR_MAP, skip building preprocessor.
在警告之后就一直卡住没往下进行了,我刚更新了fuasr版本到0.8.7也是一样的问题。
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352