Skip to content

Automodel.generate()中的punc_model 空参及None bug #2839

@noforlo

Description

@noforlo

punc_model不传参或传空字符时引发punc_res的UnboundLocalError错误。
原因是lib/python3.12/site-packages/funasr/auto/auto_model.py", line 584 的punc_res之前的函数作用域没有设置默认值:

def inference_with_vad(self, input, input_len=None, **cfg):
    # 以上省略
    # step.3 compute punc model
        raw_text = None
        if self.punc_model is not None:
            deep_update(self.punc_kwargs, cfg)
            punc_res = self.inference(
                result["text"], model=self.punc_model, kwargs=self.punc_kwargs, **cfg
            )
    # 以下省略

这是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" if args.punctuation else None,
    punc_model_revision="v2.0.4",
    device=args.device
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions