Skip to content

Funasr VAD GetFrameState index is out of bounds. #2242

@momaek

Description

@momaek

Notice: In order to resolve issues more efficiently, please raise issue following the template.
(注意:为了更加高效率解决您遇到的问题,请按照模板提问,补充细节)

🐛 Bug

ERROR:root:(Requestid:icJbZJDNCuitdTph) bt:Traceback (most recent call last):
  File "/main.py", line 152, in speech_to_txt
    result = task.transcribe(audio_for_transcribe, act_datetime, need_diarization)
  File "/speech2txt_fast_whisper.py", line 131, in transcribe
    return self.funasr_transcribe(audio, act_datetime, need_diarization)
  File "/speech2txt_fast_whisper.py", line 152, in funasr_transcribe
    res = self.funasr.transcribe(audio, need_diarization)
  File "/speech2txt_funasr.py", line 19, in transcribe
    res = self.model.generate(audio_path, batch_size_s=300, hotword='')
  File "/usr/local/lib/python3.10/dist-packages/funasr/auto/auto_model.py", line 304, in generate
    return self.inference_with_vad(input, input_len=input_len, **cfg)
  File "/usr/local/lib/python3.10/dist-packages/funasr/auto/auto_model.py", line 377, in inference_with_vad
    res = self.inference(
  File "/usr/local/lib/python3.10/dist-packages/funasr/auto/auto_model.py", line 343, in inference
    res = model.inference(**batch, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/funasr/models/fsmn_vad_streaming/model.py", line 722, in inference
    segments_i = self.forward(**batch)
  File "/usr/local/lib/python3.10/dist-packages/funasr/models/fsmn_vad_streaming/model.py", line 564, in forward
    self.DetectCommonFrames(cache=cache)
  File "/usr/local/lib/python3.10/dist-packages/funasr/models/fsmn_vad_streaming/model.py", line 760, in DetectCommonFrames
    frame_state = self.GetFrameState(
  File "/usr/local/lib/python3.10/dist-packages/funasr/models/fsmn_vad_streaming/model.py", line 518, in GetFrameState
    sum_score = cache["stats"].scores[0][t][cache["stats"].sil_pdf_ids[0]].item()
IndexError: index 210056 is out of bounds for dimension 0 with size 210054

To Reproduce

Define a global AutoModel, then call it serially. After running for a while, an error will occur.

Code sample

from funasr import AutoModel
import config
import datetime
import re

class FunASR():
    def __init__(self):
        self.model = AutoModel(
            model='iic/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch',
            vad_model='iic/speech_fsmn_vad_zh-cn-16k-common-pytorch',
            punc_model='iic/punc_ct-transformer_cn-en-common-vocab471067-large',
            spk_model='iic/speech_campplus_sv_zh-cn_16k-common',
            device="cuda",
            trust_remote_code=True,
            )

    def transcribe(self, audio_path, need_diarization):
        res = self.model.generate(audio_path, batch_size_s=300)
        return res

Expected behavior

Environment

  • OS (e.g., Linux): Linux
  • FunASR Version (e.g., 1.0.0): 1.1.14
  • ModelScope Version (e.g., 1.11.0): None
  • PyTorch Version (e.g., 2.0.0): 2.4.1
  • How you installed funasr (pip, source): pip install funasr -i https://pypi.tuna.tsinghua.edu.cn/simple
  • Python version: 3.10
  • GPU (e.g., V100M32): NVIDIA A800
  • CUDA/cuDNN version (e.g., cuda11.7): CUDA Version: 12.4
  • Docker version (e.g., funasr-runtime-sdk-cpu-0.4.1): Docker version 27.0.3, build 7d4bcd8
  • Any other relevant information:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions