speech_campplus_sv_zh-cn_16k-common 报错 object has no attribute ‘model_cfg‘

起因

NoteBook运行阿里云达摩院的模型speech_campplus_sv_zh-cn_16k-common,报错AttributeError: ‘SpeakerVerificationPipeline’ object has no attribute ‘model_cfg’;让我抓耳挠腮。

解决了,给大家避坑。

日志:

Traceback (most recent call last):
  File "main.py", line 21, in <module>
    print(p([wav1, wav2]))
  File "/opt/conda/lib/python3.7/site-packages/modelscope/pipelines/audio/speaker_verification_light_pipeline.py", line 60, in __call__
    outputs = self.preprocess(in_audios)
  File "/opt/conda/lib/python3.7/site-packages/modelscope/pipelines/audio/speaker_verification_light_pipeline.py", line 97, in preprocess
    % self.model_cfg['sample_rate'])
AttributeError: 'SpeakerVerificationPipeline' object has no attribute 'model_cfg'

解决方案和吐槽

解决了,笑死人了
在这里插入图片描述
貌似是这个函数抛出自定义错误的时候发生了问题
在这里插入图片描述
我猜,这段代码可能因为wav文件长度的原因,或者其他的不同,没被访问到过,所以bug一直没有显现,也许这个[xxx]模型之前是存在的。

改成下面这样就好了
在这里插入图片描述
我也不能让它不抛错误,但是抛出去的东西肯定不一样了,我不知道这样会不会改变原有的代码逻辑。
如果你发现有用,请务必在评论区回复“有用”,以激励我继续创作。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Deng_Xian_Sheng/article/details/130905739