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.47k stars 688 forks source link

TypeError: FunASRPipeline: GenericFunASR: 'NoneType' object is not callable #1334

Closed qx220 closed 7 months ago

qx220 commented 8 months ago

🐛 Bug

When running the the app containing the following code (directly copied from https://modelscope.cn/models/iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch/summary)

inference_pipeline = pipeline(
    task=Tasks.auto_speech_recognition,
    model='iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch',
    model_revision="v2.0.4")

the current version of funasr produces the following error

2024-02-01 00:08:25,511 - modelscope - INFO - PyTorch version 2.2.0+cpu Found.
2024-02-01 00:08:25,512 - modelscope - INFO - Loading ast index from /root/.cache/modelscope/ast_indexer
2024-02-01 00:08:25,807 - modelscope - INFO - Loading done! Current index file version is 1.11.1, with md5 56dde6840f1b32f93d591290253a7ec0 and a total number of 956 components indexed
/usr/local/lib/python3.9/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
2024-02-01 00:08:27,596 - modelscope - INFO - Use user-specified model revision: v2.0.4
2024-02-01 00:08:28,098 - modelscope - INFO - initiate model from /root/.cache/modelscope/hub/iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch
2024-02-01 00:08:28,098 - modelscope - INFO - initiate model from location /root/.cache/modelscope/hub/iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch.
2024-02-01 00:08:28,100 - modelscope - INFO - initialize model from /root/.cache/modelscope/hub/iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch
2024-02-01 00:08:33,455 - modelscope - WARNING - Model revision not specified, use revision: v2.0.0
Please Requires the ffmpeg CLI and `ffmpeg-python` package to be installed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/modelscope/utils/registry.py", line 210, in build_from_cfg
    return obj_cls._instantiate(**args)
  File "/usr/local/lib/python3.9/site-packages/modelscope/models/base/base_model.py", line 67, in _instantiate
    return cls(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/modelscope/models/audio/funasr/model.py", line 55, in __init__
    self.model = AutoModel(model=model_dir, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/funasr/auto/auto_model.py", line 102, in __init__
    vad_model, vad_kwargs = self.build_model(**vad_kwargs)
  File "/usr/local/lib/python3.9/site-packages/funasr/auto/auto_model.py", line 176, in build_model
    model = model_class(**kwargs, **kwargs["model_conf"], vocab_size=vocab_size)
TypeError: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/modelscope/utils/registry.py", line 212, in build_from_cfg
    return obj_cls(**args)
  File "/usr/local/lib/python3.9/site-packages/modelscope/pipelines/audio/funasr_pipeline.py", line 62, in __init__
    super().__init__(model=model, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/modelscope/pipelines/base.py", line 100, in __init__
    self.model = self.initiate_single_model(model, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/modelscope/pipelines/base.py", line 53, in initiate_single_model
    return Model.from_pretrained(
  File "/usr/local/lib/python3.9/site-packages/modelscope/models/base/base_model.py", line 183, in from_pretrained
    model = build_model(model_cfg, task_name=task_name)
  File "/usr/local/lib/python3.9/site-packages/modelscope/models/builder.py", line 35, in build_model
    model = build_from_cfg(
  File "/usr/local/lib/python3.9/site-packages/modelscope/utils/registry.py", line 215, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
TypeError: GenericFunASR: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/app.py", line 16, in <module>
    inference_pipeline = pipeline(task=Tasks.auto_speech_recognition, model = 'iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch', model_revision="v2.0.4", device='cpu')
  File "/usr/local/lib/python3.9/site-packages/modelscope/pipelines/builder.py", line 170, in pipeline
    return build_pipeline(cfg, task_name=task)
  File "/usr/local/lib/python3.9/site-packages/modelscope/pipelines/builder.py", line 65, in build_pipeline
    return build_from_cfg(
  File "/usr/local/lib/python3.9/site-packages/modelscope/utils/registry.py", line 215, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
TypeError: FunASRPipeline: GenericFunASR: 'NoneType' object is not callable

To Reproduce

Steps to reproduce the behavior (always include the command you ran):

Run the following code:

from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

inference_pipeline = pipeline(
    task=Tasks.auto_speech_recognition,
    model='iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch',
    model_revision="v2.0.4")

Code sample

Expected behavior

Environment

Additional context

qx220 commented 8 months ago

After testing, it seems like that the issue is on the specific model iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch

Svellsongur6 commented 8 months ago

有人解决了吗,我应该如何修改呢?

qx220 commented 8 months ago

有人解决了吗,我应该如何修改呢?

加上vad这些模型的kwargs就可以,目前我是用这个workaround:

model = AutoModel(
    task=Tasks.auto_speech_recognition,
    model = 'iic/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch',
    model_revision="v2.0.4",
    vad_model='iic/speech_fsmn_vad_zh-cn-16k-common-pytorch', vad_model_revision="v2.0.4",
    punc_model='iic/punc_ct-transformer_zh-cn-common-vocab272727-pytorch', punc_model_revision="v2.0.4",
)
LauraGPT commented 7 months ago

Please use it as demo

jinqinn commented 4 months ago

'NoneType' object is not callable

一直报错,真是搞不明白了