modelscope / FunASR

A Fundamental End-to-End Speech Recognition Toolkit and Open Source SOTA Pretrained Models, Supporting Speech Recognition, Voice Activity Detection, Text Post-processing etc.
https://www.funasr.com
Other
6.49k stars 688 forks source link

model.generate时,推理一半出现了list out of range问题 #1547

Closed Scau-Guang closed 4 months ago

Scau-Guang commented 6 months ago

🐛 Bug

When I execute model.generate() with an audio almost an hour, the error “list index out of range” appears.

To Reproduce

rtf_avg: 0.511: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:23<00:00, 23.89s/it]
rtf_avg: 0.023:  50%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                                                                                                                                    | 1/2 [00:01<00:01,  1.05s/it]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.46it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.49it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.49it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.49it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.49it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.48it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.48it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.51it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.51it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.51it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.52it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.50it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.45it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.48it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.015: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.13it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.48it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.46it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.48it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.48it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.49it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.46it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.46it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.47it/s]
rtf_avg: 0.011: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.48it/sTraceback (most recent call last):                                                                                                                                                                                                                                                                                                     | 0/1 [00:00<?, ?it/s]
  File "/root/autodl-tmp/PunctuationModel-master/mel_txt_split.py", line 544, in <module>
    txt_contents, spk_name = main(args)
  File "/root/autodl-tmp/PunctuationModel-master/mel_txt_split.py", line 453, in main
    text, timestamp, cleaned_text, cleaned_text_list = audio_asr(args.audio_path)  # 带标点文本,单词时间戳,无标点文本
  File "/root/autodl-tmp/PunctuationModel-master/mel_txt_split.py", line 275, in audio_asr
    res = model.generate(input=audio_path,
  File "/root/miniconda3/lib/python3.10/site-packages/funasr/auto/auto_model.py", line 218, in generate
    return self.inference_with_vad(input, input_len=input_len, **cfg)
  File "/root/miniconda3/lib/python3.10/site-packages/funasr/auto/auto_model.py", line 341, in inference_with_vad
    results = self.inference(speech_j, input_len=None, model=model, kwargs=kwargs, **cfg)
  File "/root/miniconda3/lib/python3.10/site-packages/funasr/auto/auto_model.py", line 251, in inference
    res = model.inference(**batch, **kwargs)
  File "/root/miniconda3/lib/python3.10/site-packages/funasr/models/seaco_paraformer/model.py", line 414, in inference
    postprocess_utils.sentence_postprocess(token, timestamp)
  File "/root/miniconda3/lib/python3.10/site-packages/funasr/utils/postprocess_utils.py", line 231, in sentence_postprocess
    word_lists, ts_lists = abbr_dispose(word_lists, ts_lists)
  File "/root/miniconda3/lib/python3.10/site-packages/funasr/utils/postprocess_utils.py", line 127, in abbr_dispose
    begin = time_stamp[ts_nums[num]][0]
IndexError: list index out of range

Code sample

相关代码:

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=audio_path,
                     batch_size_s=300,
                     hotword=hotword)

Environment

Additional context

加载funasr的模型,对1个小时左右的音频执行generate方法,报错list index out of range,只有少部分音频是没问题的。但在本地用的python 3.8跑是没问题的

taox142 commented 6 months ago

朋友,你找到原因了吗, 我也碰到类似的问题。本地ok,服务器上有问题。

Scau-Guang commented 6 months ago

你好,我已经收到来信,会尽快查看~

yzmyyff commented 6 months ago

我也遇到了一样的问题, 如果把funasr版本降级到1.0.17就没有异常了.

Wkdwlaud commented 5 months ago

我也遇到了一样的问题,请问有什么解决方案吗?

yzmyyff commented 5 months ago

我在识别一句"答案是1.5"的音频时, 必然触发此异常. 实际上模型已经正确识别了该音频, 但是在后处理的时候好像和time stamp等内容没有严格对齐, 应该和1.5的后处理有关.

R1ckShi commented 4 months ago

我在识别一句"答案是1.5"的音频时, 必然触发此异常. 实际上模型已经正确识别了该音频, 但是在后处理的时候好像和time stamp等内容没有严格对齐, 应该和1.5的后处理有关.

可以分享一下这句音频吗,我来修复一下

yzmyyff commented 4 months ago

@R1ckShi 可以参考#1698 复现

R1ckShi commented 4 months ago

看到了,那个后处理函数的问题我会修一下,这里先关掉了

jpyjpr commented 4 months ago

看到了,那个后处理函数的问题我会修一下,这里先关掉了

您好,我想问一下这个问题解决了吗?