#7307 程序内部错误:'str' object has no attribute 'get'Traceback (most recent call last):

52.7**2 Posted at: 2 hours ago

程序内部错误:'str' object has no attribute 'get'
Traceback (most recent call last):
File "videotrans\translator\_base.py", line 68, in run
File "videotrans\translator\_base.py", line 101, in _run_text
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\task\only_one.py", line 67, in run
File "videotrans\task\_stage_translate.py", line 31, in trans
File "videotrans\translator\_runner.py", line 63, in run
File "videotrans\translator\_base.py", line 74, in run
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_openaicompat.py", line 82, in _item_task
AttributeError: 'str' object has no attribute 'get'

cfg=[TaskCfgVTT]当前工作模式: 翻译视频或音频 单视频模式
原始输入文件名: D:/SetupFiles/yt-dlp/Introduction to FLIP Fluids/houdini/030-38 - Houdini Chocolate VEX Animation.mp4,
输出结果保存到文件夹: D:/SetupFiles/yt-dlp/Introduction to FLIP Fluids/houdini/030-38 - Houdini Chocolate VEX Animation-mp4,
临时文件夹: D:/SetupFiles/pyvideotrans/win-pyvideotrans-v4.05-0711/tmp/5436/1bbab4962e
未选 清理已存在
已选 启用CUDA加速
已选 降噪
语音识别:faster-whisper(本地内置), model_name: distil-large-v3.5, 发音语言: 英语, 断句方式:默认断句
翻译渠道:兼容AI/本地模型,原始语言:英语,目标语言:简体中文, 未选 发送完整字幕
配音渠道:Edge-TTS(免费), 角色:Yunxi(Male/CN), 配音语言:简体中文, 已选 二次语音识别
音量:+100%, 语速:+0%, 已选 音频加速, 已选 视频慢速
字幕: 嵌入硬字幕
代理地址:


=
system:Windows-10-10.0.26100-SP0
version:v4.05
frozen:True
language:zh
root_dir:D:/SetupFiles/pyvideotrans/win-pyvideotrans-v4.05-0711

1 Replies

#1 DeepSeek reply at 2 hours ago

`
这是因为你使用的翻译渠道是兼容AI/本地模型,而该本地服务返回的数据格式与软件预期不符(返回了字符串而非 JSON 对象),导致程序解析时报 'str' object has no attribute 'get'

解决方案:

  1. 确认本地模型服务的兼容性兼容AI/本地模型渠道要求你自行部署的服务必须严格兼容 OpenAI 的接口格式(即返回标准的 {"choices":[{"message":{"content":"..."}}]} 结构)。如果你填入的是第三方现成接口、或返回格式不同的自建服务,就会触发此错误。
  2. 检查 API 地址是否正确:在 菜单 → 翻译设置 → 兼容AI/本地模型 中确认地址填写为 http://127.0.0.1:端口号/v1(不可填 0.0.0.0),并确保本地服务已启动。
  3. 测试本地服务:用 curl 或 Postman 直接请求该地址,确认返回的是标准 OpenAI 格式的 JSON。若返回纯文本或非标准 JSON,说明该服务不被支持。
  4. 不建议新手使用本地小模型:本地部署的小模型(7B 级)指令跟随能力弱,容易输出无关内容。建议改用在线 AI 渠道,翻译质量更好、价格极低:

    • 推荐 DeepSeek:到 https://platform.deepseek.com/ 充值(支持自定义 1 元),获取 API Key 后填入 菜单 → 翻译设置 → DeepSeek,翻译渠道下拉选 Deepseek 即可。
  5. 若坚持使用本地模型,可尝试精简提示词:打开 软件目录/videotrans/prompts/srt/localllm.txt(选中"发送完整字幕"时使用)和 软件目录/videotrans/prompts/text/localllm.txt(未选中时使用),注意 {} 包裹的变量不可删除。
另需注意:你的版本为 v4.05,当前最新版为 v4.12,建议升级后重试。

请查阅相关文档:

Thinking...
Post Your Reply
If you have more than 50 messages, you will no longer receive an automatic reply. Please ask a new question!
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.

Dondate via ko-fi.com

Related resource