#4667 TaskCfgSTS(is_cuda=False, uuid='a2e3d7c243', cache_folder=None, target_dir='E:/youtube', source_language=None, source_la

123.186* Posted at: 6 hours ago 👁13

翻译字幕阶段出错 [兼容AI/本地模型] 内容太长超出最大允许Token,请减小内容或增大max_token,或者降低每次发送字幕行数
Could not parse response content as the length limit was reached - CompletionUsage(completion_tokens=4096, prompt_tokens=4096, total_tokens=8192, completion_tokens_details=None, prompt_tokens_details=None)
Traceback (most recent call last):
File "videotrans\task\job.py", line 173, in run
File "videotrans\task\_translate_srt.py", line 44, in trans
File "videotrans\translator\__init__.py", line 1000, in run
File "videotrans\translator\_base.py", line 97, in run
File "videotrans\translator\_base.py", line 161, in _run_srt
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 451, in result
File "concurrent\futures\_base.py", line 403, in __get_result
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_localllm.py", line 66, in _item_task
openai.LengthFinishReasonError: Could not parse response content as the length limit was reached - CompletionUsage(completion_tokens=4096, prompt_tokens=4096, total_tokens=8192, completion_tokens_details=None, prompt_tokens_details=None)
TaskCfgSTS(is_cuda=False, uuid='a2e3d7c243', cache_folder=None, target_dir='E:/youtube', source_language=None, source_language_code='English', source_sub='E:/youtube/Glacial Cascade Monk: Level 1 to Maps in 3_48 | Path of Exile 2.en.srt', source_wav=None, source_wav_output=None, target_language=None, target_language_code='Simplified Chinese', target_sub='E:/youtube/Glacial Cascade Monk: Level 1 to Maps in 3_48 | Path of Exile 2.en.Simplified Chinese.srt', target_wav=None, target_wav_output=None, name='E:/youtube/Glacial Cascade Monk: Level 1 to Maps in 3_48 | Path of Exile 2.en.srt', noextname='Glacial Cascade Monk: Level 1 to Maps in 3_48 | Path of Exile 2.en', basename='Glacial Cascade Monk: Level 1 to Maps in 3_48 | Path of Exile 2.en.srt', ext='srt', dirname='E:/youtube', shound_del_name=None, translate_type=8)


=
system:Windows-10-10.0.26200-SP0
version:v3.99
frozen:True
language:zh
root_dir:D:/Program Files/PotPlayer/win-pyvideotrans-v3.99-428

1 Replies

翻译字幕时出错,原因是发送给AI模型的内容(字幕+提示词)超过了模型的最大token限制(8192)。

解决方案:

  1. 取消“发送完整字幕”:在主界面或高级选项中,取消勾选“发送完整字幕”。这会将字幕逐行发送而非整体发送,大幅减少单次请求的token数。
  2. 降低“AI翻译渠道每批字幕行数”:进入菜单 → 工具/选项 → 高级选项 → 字幕翻译调整,将“AI翻译渠道每批字幕行数”设为更小值(如10或20),减少单批发送的字幕数量。
  3. 检查模型上下文窗口:如果你使用的是本地模型(如Ollama),确保模型支持至少8192个token的上下文,或改用支持更长上下文的模型(如Qwen2.5-14B、DeepSeek-V3等)。若使用在线API(如DeepSeek),可尝试增大max_tokens参数(需在API配置中手动设置,软件内暂无直接选项,建议优先调整前两步)。
  4. 取消“AI翻译附带完整原字幕”:若已开启该选项(位于高级选项-字幕翻译调整),请关闭它,以减少上下文token消耗。

请查阅相关文档:

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.

Related resource