开发者社区> 问答> 正文

使用Paraformer 最新版本,按照官方文档执行报错

from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
import soundfile

waveform, sample_rate = soundfile.read("zh_test.wav")

inference_pipeline = pipeline(
    task=Tasks.auto_speech_recognition,
    model='damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch')
rec_result = inference_pipeline(audio_in=waveform)
print(rec_result)

zh_test.wav文件与.py文件放在同一目录下

环境:直接在docker上pull 官方提供的镜像

registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-py37-torch1.11.0-tf1.15.5-1.2.0

error log如下:

2023-02-09 17:39:58,452 (asr_inference_pipeline:278) INFO: Decoding with pcm files ...
Traceback (most recent call last):
  File "modelscope_test.py", line 10, in <module>
    rec_result = inference_pipeline(audio_in=waveform)
  File "/opt/conda/lib/python3.7/site-packages/modelscope/pipelines/audio/asr_inference_pipeline.py", line 136, in __call__
    output = self.forward(output)
  File "/opt/conda/lib/python3.7/site-packages/modelscope/pipelines/audio/asr_inference_pipeline.py", line 305, in forward
    inputs['asr_result'] = self.run_inference(self.cmd)
  File "/opt/conda/lib/python3.7/site-packages/modelscope/pipelines/audio/asr_inference_pipeline.py", line 382, in run_inference
    output_dir_v2=cmd['output_dir'])
  File "/opt/conda/lib/python3.7/site-packages/funasr/bin/asr_inference_paraformer.py", line 618, in _forward
    results = speech2text(**batch)
  File "/opt/conda/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/funasr/bin/asr_inference_paraformer.py", line 203, in __call__
    feats, feats_len = self.frontend.forward(speech, speech_lengths)
  File "/opt/conda/lib/python3.7/site-packages/funasr/models/frontend/wav_frontend.py", line 131, in forward
    sample_frequency=self.fs)
  File "/opt/conda/lib/python3.7/site-packages/torchaudio/compliance/kaldi.py", line 614, in fbank
    preemphasis_coefficient,
  File "/opt/conda/lib/python3.7/site-packages/torchaudio/compliance/kaldi.py", line 177, in _get_window
    strided_input = _get_strided(waveform, window_size, window_shift, snip_edges)
  File "/opt/conda/lib/python3.7/site-packages/torchaudio/compliance/kaldi.py", line 59, in _get_strided
    assert waveform.dim() == 1
AssertionError

不清楚为什么会报错,以及不知道如何解决

展开
收起
little_ant0 2023-02-09 17:51:41 510 0
1 条回答
写回答
取消 提交回答
  • GitHub https://github.com/co63oc/cloud

    没有错误信息

    2023-02-09 20:18:11
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载