#6975 Could not parse response content as the length limit was reached - CompletionUsage(completion_tokens=8192, prompt_tokens

45.58**6 Posted at: 1 hour ago

Could not parse response content as the length limit was reached - CompletionUsage(completion_tokens=8192, prompt_tokens=1001, total_tokens=9193, completion_tokens_details=None, prompt_tokens_details=None)
Traceback (most recent call last):
File "videotrans\translator\_base.py", line 68, in run
File "videotrans\translator\_base.py", line 107, 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 89, in run
File "videotrans\task\_stage_translate.py", line 31, in trans
File "videotrans\translator\_runner.py", line 67, 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 105, in _item_task
openai.LengthFinishReasonError: Could not parse response content as the length limit was reached - CompletionUsage(completion_tokens=8192, prompt_tokens=1001, total_tokens=9193, completion_tokens_details=None, prompt_tokens_details=None)

cfg=[TaskCfgVTT]当前工作模式: 翻译视频 单视频模式
原始输入文件名: C:/Users/Francis/Videos/mui le.mp4,
输出结果保存到文件夹: C:/Users/Francis/Videos/_video_out/mui le-mp4,
临时文件夹: C:/AIDubbingSuite/Apps/pyVideoTrans/tmp/31148/e1690e23c2
未选 清理已存在
已启用CUDA加速
未选 降噪
STT Service:faster-whisper(Built-in), medium, 发音语言: Vietnamese, 断句方式:默认断句
TranslateSrt:CompatibleAI/LocalModel,原始语言:Vietnamese,目标语言:English, 未选 SendSRT
TTS Service:GPT-SoVITS(LocalAPI), 角色:clone, 配音语言:English, 未选 二次语音识别
音量:+0%, 语速:+0%, 未选 音频加速, 未选 视频慢速
未选 移除字幕间空隙, 未选 强制对齐字幕和声音
字幕: No Subtitles
已选 分离人声与背景声, 已选 重新嵌入背景声, 背景音量0.8, 背景声音时长 短于 视频时长时: 拉长(降速播放),存在分离后的纯净人声文件,存在分离后的背景声音文件
已选 仅输出mp4


=
system:Windows-10-10.0.19045-SP0
version:v4.11
frozen:True
language:en
root_dir:C:/AIDubbingSuite/Apps/pyVideoTrans

1 Replies

#1 DeepSeek reply at 1 hour ago

This error is caused by the AI model hitting its maximum output token limit before it could finish generating the translation. Specifically, completion_tokens=8192 indicates the model reached the hard cap of 8192 tokens mid-response, and the response was truncated, leading to LengthFinishReasonError.

This happens because too many subtitle lines are being sent to the AI in a single translation request.

How to fix it:

  1. Reduce the AI translation batch size

    • Go to Menu -> Tools/Options -> Advanced Options -> Subtitle Translation Adjustments
    • Set AI translation channel subtitles per batch to a lower value, e.g., 1–5 (start with 1 to test)
  2. Turn off "Translate all subtitles at once" if enabled

    • In the same advanced options panel, uncheck AI translation translates all subtitles at once
    • This feature sends the entire subtitle file in one request, which almost always exceeds token limits
  3. Increase the max_token setting in your AI channel configuration

    • Open the CompatibleAI/LocalModel settings
    • Look for the max token field and set it to a higher value (e.g., 16384 or 32768) if your model/API supports it
  4. Alternatively, use a simpler translation channel

    • For basic translations, you can switch to Google (Free) or M2M100 (Local) instead of the AI model, avoiding token limit issues entirely

After making these changes, clear the translation cache at tmp/translate_cache/ to avoid using any previously cached bad results, then retry.

Please refer to related documentation:

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