#809 RuntimeError: local variable 'raw_subtitles' referenced before assignment

*123.41* Posted at: 21 hours ago 👁9

local variable 'raw_subtitles' referenced before assignment:Traceback (most recent call last):

File "videotrans\recognition\_base.py", line 70, in run

File "tenacity\__init__.py", line 338, in wrapped_f

File "tenacity\__init__.py", line 477, in __call__

File "tenacity\__init__.py", line 378, in iter

File "tenacity\__init__.py", line 421, in exc_check

tenacity.RetryError: RetryError[]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "videotrans\util\TestSTT.py", line 18, in run

File "videotrans\recognition\__init__.py", line 217, in run

File "videotrans\recognition\_base.py", line 72, in run

File "tenacity\__init__.py", line 480, in __call__

File "videotrans\recognition\_stt.py", line 69, in _exec

RuntimeError: local variable 'raw_subtitles' referenced before assignment

=====

Windows-10-10.0.26100-SP0

version:v3.80

frozen:True

language:zh

1 Replies

本条内容由 DeepSeek 回复
这个错误是由于语音识别过程中出现了异常,导致变量 raw_subtitles 在赋值前就被引用。从错误日志可以看到,这发生在使用 faster-whisper 进行语音识别时,出现了 tenacity.RetryError 重试错误。

问题原因分析:

1. 语音识别服务(faster-whisper)在尝试多次重试后仍然失败

2. 在错误处理过程中,变量 raw_subtitles 没有被正确初始化就被引用

3. 这通常发生在网络连接问题、模型下载失败或显存不足的情况下

解决方案:

1. 检查网络连接和模型下载

  • 如果使用 faster-whisper 在线下载模型,请确保网络连接稳定
  • 如果模型下载失败,可以尝试:
  • 在软件目录下创建 huggingface.lock 文件,强制从官网下载
  • 使用专门的模型下载工具从官网或镜像站下载

2. 检查显存和系统资源

  • 如果视频较大或使用 large 模型,可能出现显存不足
  • 尝试使用 smaller 模型(如 base、small)
  • 关闭其他占用显存的应用程序

3. 更换语音识别渠道

  • 在"语音识别设置"中尝试其他识别渠道,如:
  • 阿里FunASR(对中文效果较好)
  • 字节火山字幕生成
  • Google识别API(需要科学上网)

4. 检查输入文件

  • 确保音频/视频文件没有损坏
  • 确认文件包含有效的人声内容

5. 查看详细日志

  • 进入软件目录下的 logs 文件夹
  • 打开以当前日期命名的 .log 文件
  • 查看底部的详细错误信息,这有助于进一步诊断问题

如果问题持续存在,建议尝试重新安装软件或从官网下载最新版本。

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