#1806 TaskCfg(cache_folder='F:/win-pyvideotrans-v3.87/tmp/8684/speech2text', target_dir='F:/win-pyvideotrans-v3.87/output/reco

240e:3b2* Posted at: 2 days ago 👁23

语音识别阶段出错:[阿里FunASR中文(本地)] 无效的值或参数:cannot process flags argument with a compiled pattern:
Traceback (most recent call last):
File "videotrans\task\job.py", line 113, in run
File "videotrans\task\_speech2text.py", line 146, in recogn
File "videotrans\recognition\__init__.py", line 231, in run
File "videotrans\recognition\_base.py", line 78, in run
File "videotrans\recognition\_funasr.py", line 39, in _exec
File "videotrans\recognition\_funasr.py", line 126, in _exec1
File "videotrans\recognition\_funasr.py", line 27, in remove_unwanted_characters
File "re.py", line 209, in sub
File "re.py", line 298, in _compile
ValueError: cannot process flags argument with a compiled pattern

TaskCfg(cache_folder='F:/win-pyvideotrans-v3.87/tmp/8684/speech2text', target_dir='F:/win-pyvideotrans-v3.87/output/recogn', remove_noise=False, is_separate=False, detect_language='yue', subtitle_language=None, source_language=None, target_language=None, source_language_code=None, target_language_code=None, source_sub=None, target_sub='F:/win-pyvideotrans-v3.87/output/recogn/2025.11.02-12.26.47.srt', source_wav=None, source_wav_output=None, target_wav=None, target_wav_output=None, subtitles=None, novoice_mp4=None, noextname='2025.11.02-12.26.47', shibie_audio='F:/win-pyvideotrans-v3.87/tmp/8684/speech2text/2025.11.02-12.26.47-1765001015.8365147.wav', targetdir_mp4=None, instrument=None, vocal=None, back_audio=None, background_music=None, app_mode='biaozhun', subtitle_type=0, volume='+0%', pitch='+0Hz', voice_rate='+0%', voice_role=None, copysrt_rawvideo=False, clear_cache=False, translate_type=None, tts_type=None, recogn_type=2, model_name='SenseVoiceSmall', split_type=0, voice_autorate=False, video_autorate=False, cuda=False, name='C:/Users/abc/Videos/4K Video Downloader+/2025.11.02-12.26.47.aac', basename='2025.11.02-12.26.47.aac', ext='aac', dirname='C:/Users/abc/Videos/4K Video Downloader+', shound_del_name=None, uuid='c69a004c0e', remove_silent_mid=False, align_sub_audio=True, enable_diariz=False, nums_diariz=0, rephrase=0)


=
system:Windows-10-10.0.26200-SP0
version:v3.87
frozen:True
language:zh
root_dir:F:/win-pyvideotrans-v3.87

3 Replies

错误信息显示在使用阿里FunASR进行语音识别时,正则表达式处理出错。从配置中看到 detect_language='yue'(粤语),而阿里FunASR是中文语音识别模型,主要针对普通话,对粤语的支持可能不完善或存在兼容性问题。

请按以下步骤解决:

  1. 更换语音识别模型:这是最直接的解决方案。在软件主界面第2行“语音识别”中,将模型从“阿里FunASR中文(本地)”切换为 “faster-whisper(本地)”
  2. 调整语言设置:使用 faster-whisper 时,确保“发音语言”正确设置为 yue(粤语)auto(自动检测)。
  3. 模型选择:faster-whisper 的 large-v3 模型对多语言(包括粤语)支持较好,如果识别效果不佳,可尝试下载并切换到此模型。

如果必须使用阿里FunASR,且确认音频是普通话,请将“发音语言”从 yue 改为 zh(中文)后重试。但鉴于错误是代码层面的正则标志问题,更换模型是更稳妥的方案。

用的是SenseVoiceSmall模型,它不是支持普通话、粤语、英语、日语、韩语吗?

您说得对,SenseVoiceSmall 模型确实支持多语言,包括粤语。错误的核心不是模型不支持,而是软件在处理识别结果时,正则表达式模块的 flags 参数传递出现了内部代码问题。

这是一个软件内部的 Bug。当使用阿里FunASR(特别是SenseVoice系列模型)进行识别,且目标语言为某些特定语言(如粤语 yue)时,触发了这个错误。

解决方案如下:

  1. 临时规避(推荐):在修复此 Bug 之前,最有效的解决方法是更换语音识别引擎

    • 在主界面第2行“语音识别”中,将模型从 “阿里FunASR中文(本地)” 切换为 “faster-whisper(本地)”
    • 将“发音语言”设置为 yueauto
    • faster-whisperlarge-v3 模型对粤语有很好的支持,识别准确率很高。
  2. 尝试修改配置(可能无效):如果坚持使用阿里FunASR,可以尝试:

    • 在“识别设置”中,将“发音语言”从 yue 暂时改为 zh(中文普通话),看是否能正常识别(如果您的音频确实是粤语,识别结果会不准确)。
    • 这个操作是为了验证是否特定语言代码触发了Bug,并不能解决粤语识别问题。
  3. 反馈问题:您可以到项目的 GitHub Issues 页面提交此错误报告,附上您的错误日志,帮助开发者定位和修复这个 re.compile 的 flags 参数错误。

结论:目前,使用 faster-whisper 是绕过此 Bug、顺利完成粤语语音识别的最可靠方法。

Post Your Reply
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Donate: https://ko-fi.com/jianchang512

Trending Questions