#2711 videotrans.configure._except.StopRetry: local variable 'raw_subtitles' referenced before assignment

218.1* Posted at: 2 hours ago 👁6

local variable 'raw_subtitles' referenced before assignment:
Traceback (most recent call last):
File "videotrans\util\TestSTT.py", line 18, in run
File "videotrans\recognition\__init__.py", line 214, in run
File "videotrans\recognition\_base.py", line 80, 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 400, in
File "concurrent\futures\_base.py", line 439, in result
File "concurrent\futures\_base.py", line 391, in __get_result
File "tenacity\__init__.py", line 480, in call
File "videotrans\recognition\_stt.py", line 70, in _exec
videotrans.configure._except.StopRetry: local variable 'raw_subtitles' referenced before assignment


=
system:Windows-10-10.0.26200-SP0
version:v3.92
frozen:True
language:zh
root_dir:D:/videotrans

1 Replies

这个错误表明在使用自定义语音识别API(STT)时,程序未能正确获取到识别结果,导致变量 raw_subtitles 在赋值前被引用。

核心原因: 您配置的自定义语音识别API接口返回的数据格式不符合软件预期。

解决步骤:

  1. 检查API配置: 请确保您在“翻译设置”->“自定义语音识别API”中填写的URL地址正确无误,并且该API服务正在运行。
  2. 验证API返回格式: 您的自定义API必须返回一个JSON对象,且该对象必须包含一个名为 text 的字段,其值为识别出的文本字符串。

    • 正确示例: {"text": "这是识别出的字幕内容。"}
    • 错误示例: "这是识别出的字幕内容。" (纯字符串,非JSON) 或 {"result": "这是识别出的字幕内容。"} (字段名不是 text)。
  3. 使用测试功能: 在“翻译设置”->“自定义语音识别API”配置页面,点击“测试”按钮。如果测试失败,软件会提示具体的错误信息,请根据提示修正您的API。
  4. 查看API日志: 检查您自定义API服务的日志,确认它是否收到了请求、处理是否成功、以及返回的数据是否符合上述格式。
  5. 临时解决方案: 如果您无法立即修正API,可以暂时切换到其他语音识别渠道(如 faster-whisper(本地))来完成当前任务。

请查看更多参考文档:

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