#4984 TaskCfgSTT(uuid='1405fca7b7', name='D:/ZJJ/Desktop/素材/德国搭便车-副本.mp4', dirname='D:/ZJJ/Desktop/素材', noextname='德国搭便车-副本',

2406:da14* Posted at: 9 hours ago

语音识别阶段出错[WhisperX] 程序内部错误:'NoneType' object has no attribute 'rstrip'
Traceback (most recent call last):

File "videotrans\task\job.py", line 35, in run

File "videotrans\task\job.py", line 100, in process_task

File "videotrans\task\speech2text.py", line 126, in recogn

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

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

File "videotrans\recognition\_whisperx.py", line 24, in _exec

AttributeError: 'NoneType' object has no attribute 'rstrip'
TaskCfgSTT(uuid='1405fca7b7', name='D:/ZJJ/Desktop/素材/德国搭便车-副本.mp4', dirname='D:/ZJJ/Desktop/素材', noextname='德国搭便车-副本', basename='德国搭便车-副本.mp4', ext='mp4', target_dir='D:/win-pyvideotrans-v4.01-0602/output/recogn', cache_folder='D:/win-pyvideotrans-v4.01-0602/tmp/21732/1405fca7b7', is_cuda=True, source_language=None, source_language_code=None, source_sub=None, source_wav=None, source_wav_output=None, target_language=None, target_language_code=None, target_sub='D:/win-pyvideotrans-v4.01-0602/output/recogn/德国搭便车-副本.srt', target_wav=None, target_wav_output=None, detect_language='de', recogn_type=14, model_name='large-v3', shibie_audio='D:/win-pyvideotrans-v4.01-0602/tmp/21732/1405fca7b7/德国搭便车-副本-1780647654.0907943.wav', remove_noise=True, enable_diariz=False, nums_diariz=0, rephrase=0, fix_punc=False)


=
system:Windows-10-10.0.26220-SP0
version:v4.01
frozen:True
language:zh
root_dir:D:/win-pyvideotrans-v4.01-0602

29 Replies

WhisperX 渠道的内部错误 'NoneType' object has no attribute 'rstrip' 表明 WhisperX API 后端返回了空数据或未正确初始化,导致程序处理时触发了属性访问异常。

解决方案:

  1. 确认 WhisperX API 服务已启动:WhisperX 需要额外独立部署后端服务,请检查对应的 API 服务进程是否正常运行,端口是否正确。
  2. 检查 API 地址配置:在菜单栏 → 语音识别设置 → WhisperX 中,确保填写的 URL(例如 http://127.0.0.1:端口)正确无误,且服务端无认证或路径错误。
  3. 尝试其他识别渠道:暂时改用 faster-whisper(本地)openai-whisper(本地) 等直接集成的渠道,验证音频文件本身是否正常。若其他渠道可成功识别,则问题定位为 WhisperX 后端配置或服务异常。
  4. 查看服务端日志:检查 WhisperX 后端的控制台或日志输出,确认是否有模型加载失败、显存不足或请求超时等具体错误。

请查阅相关文档:

WhisperX不能像faster-whisper那样使用吗?

不能。WhisperX 是本地 API 渠道,需要您单独部署 WhisperX 后端服务(如 pyvideotrans.com/whisperx-api),并在软件设置中填写 API 地址和端口。它不像 faster-whisper(本地) 那样开箱即用、直接集成在软件内。如果您希望免配置使用,建议改用 faster-whisper(本地)openai-whisper(本地)

可faster-whisper时间轴不准确

faster-whisper 时间轴不准确通常由默认的 VAD 参数导致。请按以下步骤优化:

  1. 打开 菜单 → 工具/选项 → 高级选项 → 语音识别参数
  2. 最短语音持续毫秒 设为 100(降低过短片段被舍弃的概率)。
  3. 静音分割持续毫秒 设为 200 左右(更细粒度的切割)。
  4. 选中 Whisper预分割音频?(用 VAD 预先按句子切分后再识别,时间轴更匹配实际语音)。
  5. 若视频背景噪音较大,勾选主界面 降噪分离人声背景声
  6. 另外可尝试使用 large-v3 模型,并勾选 CUDA加速 提升性能。

若仍需更精准的时间轴,可考虑改用 openai-whisper(本地) + large-v3,其时间轴标注通常更稳定。

faster-whisper咋这么慢呢

faster-whisper 速度慢的核心原因是 未启用 GPU 加速使用了过大的模型。请依次检查:

  1. 确认勾选了 CUDA 加速:主界面右上角 CUDA加速 复选框必须勾选。
  2. 确认 CUDA 环境正确:在命令提示符执行 nvcc -Vnvidia-smi,确保驱动支持 CUDA 12.8+,且已安装 cuDNN 9.11+。
  3. 选择较小的模型large-v3 约需 8GB 显存且速度较慢,可先改用 mediumsmall 验证速度是否明显提升。若仍慢,说明 GPU 未被调用,请按步骤 2 排查环境变量。
  4. 首次运行需下载模型:若首次启动,模型需在线下载,此时界面可能显示无反应,请耐心等待下载完成。
  5. 调整高级选项:若已启用 GPU 仍慢,可尝试在 菜单→工具→高级选项→语音识别参数 中降低 beam_sizebest_of1,并选用 int8 数据类型以减少显存和计算开销。

请查阅相关文档:

还是慢

如果已经勾选 CUDA加速 并确认环境无误后依然慢,请按以下优先级排查:

  1. 确认 GPU 实际被调用:处理时打开任务管理器 -> 性能 -> GPU,观察“CUDA”或“Compute”使用率。若 GPU 利用率接近 0%,说明未正确调用。请检查系统环境变量 Path 中是否包含 CUDA 的 binlib 目录(例如 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\bin),并重启软件。
  2. 使用最小模型测试:在“语音识别”下拉框中选择 faster-whisper,模型选 tiny。若 tiny 仍然极慢,则肯定是 GPU 未工作。若 tiny 很快,说明模型过大导致显存瓶颈,此时应:

    • 改用 basesmall 模型。
    • 在菜单 -> 工具/选项 -> 高级选项 -> 语音识别参数中,将 CUDA数据类型 改为 int8beam_sizebest_of 均设为 1。
  3. 检查是否为 CPU 模式:打开软件根目录 logs/ 下的日志文件,搜索 "use_cuda" 或 "cuda",看是否显示为 False。
  4. 尝试替代渠道:如果目的是快速获取字幕,建议改用在线 API:

    • 字节语音识别大模型极速版(需 API Key,速度快且中文效果好)
    • 阿里百炼 Qwen3-ASR(在线 API,速度快)
      它们不依赖本地 GPU,速度显著优于本地模型。
  5. 视频本身因素:视频时长过长、采样率高、有大量背景噪音都会降低识别速度。可先截取 1 分钟片段测试速度,定位瓶颈。

若以上仍无法解决,请提供 logs/ 目录下的最新日志文件(复制末尾 30 行)以便进一步分析。

target_wav_output='D:/ZJJ/Desktop/素材/剪映/字幕/德国搭便车-mp4/zh-cn.m4a', translate_type=0, tts_type=0, volume='+0%', pitch='+0Hz', voice_rate='+0%', voice_role='No', voice_autorate=True, video_autorate=False, remove_silent_mid=False, align_sub_audio=True, detect_language='de', recogn_type=0, model_name='large-v3', shibie_audio=None, remove_noise=False, enable_diariz=False, nums_diariz=0, rephrase=0, fix_punc=False, subtitle_language=None, app_mode='biaozhun', subtitles='', targetdir_mp4='D:/ZJJ/Desktop/素材/剪映/字幕/德国搭便车-mp4/德国搭便车.mp4', novoice_mp4='D:/win-pyvideotrans-v4.01-0602/tmp/24108/8040af8199/novoice.mp4', is_separate=False, embed_bgm=True, instrument=None, vocal=None, clear_cache=True, background_music='', subtitle_type=1, only_out_mp4=False, recogn2pass=False, output_srt=0, copysrt_rawvideo=False, loop_backaudio=1, backaudio_volume=0.8)
[DEBUG] The file info after process:result={'video_fps': 30.0, 'r_frame_rate': '30/1', 'video_codec_name': 'h264', 'audio_codec_name': 'aac', 'width': 1920, 'height': 1080, 'time': 173033, 'streams_len': 2, 'streams_audio': 1, 'video_streams': 1, 'color': 'yuv420p'}
[DEBUG] [FFMPEG-CMD]:
ffmpeg -hide_banner -nostdin -ignore_unknown -threads 0 -y -fflags +genpts -i D:/ZJJ/Desktop/素材/德国搭便车.mp4 -an -c:v copy novoice.mp4

[DEBUG] 开始语音识别:渠道0
[DEBUG] Before VAD silero,_min_speech=100ms,_max_speech=5000ms,_min_silence=200ms
[DEBUG] [新进程任务 开始:VAD:silero split audio...]
[DEBUG] 任务参数:kwargs={'input_wav': 'D:/win-pyvideotrans-v4.01-0602/tmp/24108/8040af8199/de.wav', 'threshold': 0.5, 'min_speech_duration_ms': 100, 'max_speech_duration_ms': 5000, 'min_silent_duration_ms': 200}
[DEBUG] [silero-VAD]Fix:VAD断句参数:threshold=0.5,min_speech_duration_ms=0ms,max_speech_duration_ms=5000ms,min_silent_duration_ms=200ms
[DEBUG] [新进程任务 结束:VAD:silero split audio...],耗时10.531172513961792s
[DEBUG] [新进程任务 开始:STT use large-v3]
[DEBUG] 任务参数:kwargs={'detect_language': 'de', 'model_name': 'large-v3', 'logs_file': 'D:/win-pyvideotrans-v4.01-0602/tmp/24108/8040af8199/faster-de-1780650442.5001576.log', 'is_cuda': True, 'no_speech_threshold': 0.6, 'condition_on_previous_text': False, 'speech_timestamps': 'D:/win-pyvideotrans-v4.01-0602/tmp/24108/8040af8199/speech_timestamps_1780650442.4978545.json', 'audio_file': 'D:/win-pyvideotrans-v4.01-0602/tmp/24108/8040af8199/de.wav', 'local_dir': 'D:/win-pyvideotrans-v4.01-0602/models/models--Systran--faster-whisper-large-v3', 'compute_type': 'default', 'jianfan': False, 'audio_duration': 173035, 'hotwords': '', 'prompt': '', 'beam_size': 1, 'best_of': 1, 'temperature': '', 'repetition_penalty': 1.0, 'compression_ratio_threshold': 2.4, 'max_speech_ms': 5000, 'device_index': 0}
[DEBUG] 新进程执行结束结束timeout=10

根据日志,处理流程正常,未发现错误。当前状态:视频时长约 2.9 分钟,使用 faster-whisper + large-v3 模型,VAD 预分割耗时约 10.5 秒,STT 子进程已启动(计算类型 default,显存充足时通常使用 float16)。STT 子进程的 timeout=10 仅为调试日志的输出标记,不影响实际执行。如果觉得速度慢,可尝试:改用 smallmedium 模型;在 菜单 → 工具/选项 → 高级选项 → 语音识别参数 中将 CUDA数据类型 设为 int8;确认 GPU 使用率在任务管理器中是否爬升(NVIDIA 显卡的 CUDA 计算)。若仍有其他疑问,请明确描述问题。

Traceback (most recent call last):
File "videotrans\task\speech2text.py", line 186, in recogn
File "videotrans\translator\_openaicompat.py", line 158, in llm_segment
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 "logging\__init__.py", line 1103, in emit
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
File "videotrans\task\job.py", line 35, in run
File "videotrans\task\job.py", line 100, in process_task
File "videotrans\task\speech2text.py", line 194, in recogn
File "logging\__init__.py", line 1512, in exception
File "logging\__init__.py", line 1506, in error
File "logging\__init__.py", line 1624, in _log
File "logging\__init__.py", line 1634, in handle
File "logging\__init__.py", line 1696, in callHandlers
File "logging\__init__.py", line 968, in handle
File "logging\__init__.py", line 1108, in emit
Message: '重新断句失败已恢复原样 RetryError[]'
Arguments: ()

错误源于 LLM重新断句 功能在重试多次后失败,最终日志写入异常(不影响主流程)。根本原因是 AI 渠道 API 调用失败。请按以下步骤排查:1. 关闭 LLM 重新断句:打开菜单 → 工具/选项 → 高级选项 → 通用设置,将“LLM重新断句”设为“默认断句”或取消其启用状态,避免调用 AI 接口。2. 检查 LLM 重新断句所用 AI 渠道配置:在相同高级选项页面,确认“LLM重新断句所用AI渠道”已正确填写 API Key 和接口地址(如 DeepSeek 或 OpenAI ChatGPT)。若未配置,请先配置或改用可用的渠道。3. 调整重试与超时:若仍需启用 LLM 断句,可适当增加“失败后重试次数”(高级选项 → 通用设置)或调整提示词(软件根目录 videotrans/prompts/recharge/ 中的模板)。4. 查看网络连接:确保软件能正常访问该 AI 渠道(国内访问可能需要代理,检查主界面“网络代理”是否设置正确)。

怎么能确认LLM重新断句API设置成功呢

要确认 LLM 重新断句 API 配置是否成功,可按以下步骤验证:打开菜单 → 工具/选项 → 高级选项 → 通用设置。确保“LLM重新断句所用AI渠道”已选择正确的渠道(例如 DeepSeek 或 OpenAI ChatGPT)。然后进入该 AI 渠道的设置面板(菜单 → 翻译设置 → 对应渠道),确认以下信息已正确填写:API Key(或 SK 密钥)Base URL(若渠道为兼容 AI/本地模型,需填写正确的地址,如 https://api.deepseek.com)模型名称(如 deepseek-chat、gpt-4o 等)在 AI 渠道设置面板中点击“测试”或“试听翻译”按钮(若有),验证网络连通性及密钥有效性。若没有测试按钮,可执行一次简单任务来验证:选择一段短音频或字幕,在菜单 → 工具/选项 → 高级选项 → 通用设置中开启“LLM重新断句”(设为“启用”),然后运行一次标准语音识别或视频翻译任务。观察日志(软件根目录 logs/ 下)是否出现类似“正在调用[渠道名]进行LLM重新断句...”的条目,且最终字幕断句比默认更自然流畅,无相关报错,即表示配置成功。若日志中出现“重新断句失败”或网络错误,则需检查 API 密钥、URL 及代理设置。

测试成功了,但是还是提示这个[ERROR] 重新断句失败已恢复原样 RetryError[]
Traceback (most recent call last):

API 测试成功但实际执行仍失败,常见原因是 每批字幕行数过多导致请求超时或超出模型上下文长度。请按以下步骤调整:

  1. 减少每批字幕行数
    打开菜单 → 工具/选项 → 高级选项 → 通用设置,将“LLM重新断句每批字幕行数”从默认值降低到 10 或 5,避免单次请求数据过大。
  2. 增加重试次数
    同一页面将“失败后重试次数”设为 3 或 5,应对临时性网络抖动。
  3. 检查 AI 渠道的 Max Token 设置
    进入该 AI 渠道的设置面板(菜单 → 翻译设置 → 对应渠道),确认 max token 足够大(建议 4096 或 8192),否则长字幕会被截断导致 API 报错。
  4. 确认网络代理稳定
    若使用代理,请确保主界面“网络代理”地址正确且连接稳定(格式如 http://127.0.0.1:7890)。代理不稳定会导致偶发失败。
  5. 临时解决方案
    若以上调整后仍频繁失败,建议暂时关闭 LLM 重新断句(改为“默认断句”),该功能非必需,不影响核心翻译配音流程。

[ERROR] 重新断句失败已恢复原样 RetryError[]
Traceback (most recent call last):
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_openaicompat.py", line 131, in _send
File "openai\_utils\_utils.py", line 298, in wrapper
File "openai\resources\chat\completions\completions.py", line 1215, in create
File "openai\_base_client.py", line 1332, in post
File "openai\_base_client.py", line 1105, in request
openai.RateLimitError: Error code: 429 - {'error': {'message': 'max_tokens is too large: 65536. This model supports at most 32768 completion tokens, whereas you provided 65536. (request id: 20260605175336886573320U5gw8s9n)', 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'invalid_value'}}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "videotrans\task\speech2text.py", line 186, in recogn
File "videotrans\translator\_openaicompat.py", line 158, in llm_segment
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[]


Logging error

Traceback (most recent call last):
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_openaicompat.py", line 131, in _send
File "openai\_utils\_utils.py", line 298, in wrapper
File "openai\resources\chat\completions\completions.py", line 1215, in create
File "openai\_base_client.py", line 1332, in post
File "openai\_base_client.py", line 1105, in request
openai.RateLimitError: Error code: 429 - {'error': {'message': 'max_tokens is too large: 65536. This model supports at most 32768 completion tokens, whereas you provided 65536. (request id: 20260605175336886573320U5gw8s9n)', 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'invalid_value'}}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "videotrans\task\speech2text.py", line 186, in recogn
File "videotrans\translator\_openaicompat.py", line 158, in llm_segment
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 "logging\__init__.py", line 1103, in emit
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
File "videotrans\task\job.py", line 35, in run
File "videotrans\task\job.py", line 100, in process_task
File "videotrans\task\speech2text.py", line 194, in recogn
File "logging\__init__.py", line 1512, in exception
File "logging\__init__.py", line 1506, in error
File "logging\__init__.py", line 1624, in _log
File "logging\__init__.py", line 1634, in handle
File "logging\__init__.py", line 1696, in callHandlers
File "logging\__init__.py", line 968, in handle
File "logging\__init__.py", line 1108, in emit
Message: '重新断句失败已恢复原样 RetryError[]'
Arguments: ()

原因明确:您在 LLM 重新断句所用的 AI 渠道设置中,将 max_tokens 设置为了 65536,但该模型(例如 DeepSeek V2/V3)只支持最多 32768 个 completion tokens。因此 API 返回 429 错误(实际是参数无效),导致重新断句失败。修改方法:打开菜单 → 翻译设置 → 对应 AI 渠道(如 DeepSeek / OpenAI ChatGPT),将 max token 参数改为 ≤32768 的值,建议设为 40968192。保存后重试即可。同时可顺带确认“每批字幕行数”不要过大(建议 5~10 行),避免超出模型上下文窗口。

现在就是8192

您已改为 8192,但日志显示之前报错时 max_tokens 为 65536,说明报错发生在修改前。现在您已修改,请执行一次新任务测试。如果仍报类似错误,请检查以下两点:确认设置是否已保存:打开菜单 → 翻译设置 → 对应 AI 渠道,查看 max_tokens 字段是否显示为 8192。若显示正常,尝试先修改为其他值(如 4096)保存后再改回 8192,确保配置文件写入。确认渠道和模型名称:部分模型(如 deepseek-chat 旧版)最大输出为 32768,若您填写的模型名称指向旧版本,仍可能触发限制。建议检查渠道文档确认当前模型支持的 max_tokens 上限。若已确认无误,请提供新任务的日志底部 30 行以便进一步分析。

[INFO] Finished call to 'videotrans.translator._openaicompat.OpenAICampat.llm_segment.._send' after 4.234(s), this was the 1st time calling it.
[INFO] Starting call to 'videotrans.translator._openaicompat.OpenAICampat.llm_segment.._send', this is the 2nd time calling it.
[INFO] Finished call to 'videotrans.translator._openaicompat.OpenAICampat.llm_segment.._send' after 13.328(s), this was the 2nd time calling it.
[ERROR] 重新断句失败,已恢复原样 RetryError[]
Traceback (most recent call last):
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_openaicompat.py", line 131, in _send
File "openai\_utils\_utils.py", line 298, in wrapper
File "openai\resources\chat\completions\completions.py", line 1215, in create
File "openai\_base_client.py", line 1332, in post
File "openai\_base_client.py", line 1105, in request
openai.RateLimitError: Error code: 429 - {'error': {'message': 'max_tokens is too large: 65536. This model supports at most 32768 completion tokens, whereas you provided 65536. (request id: 2026060518175295128127470wO0u6r)', 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'invalid_value'}}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "videotrans\task\trans_create.py", line 390, in recogn
File "videotrans\translator\_openaicompat.py", line 158, in llm_segment
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[]


Logging error

Traceback (most recent call last):
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_openaicompat.py", line 131, in _send
File "openai\_utils\_utils.py", line 298, in wrapper
File "openai\resources\chat\completions\completions.py", line 1215, in create
File "openai\_base_client.py", line 1332, in post
File "openai\_base_client.py", line 1105, in request
openai.RateLimitError: Error code: 429 - {'error': {'message': 'max_tokens is too large: 65536. This model supports at most 32768 completion tokens, whereas you provided 65536. (request id: 2026060518175295128127470wO0u6r)', 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'invalid_value'}}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "videotrans\task\trans_create.py", line 390, in recogn
File "videotrans\translator\_openaicompat.py", line 158, in llm_segment
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 "logging\__init__.py", line 1103, in emit
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
File "videotrans\task\job.py", line 35, in run
File "videotrans\task\job.py", line 100, in process_task
File "videotrans\task\trans_create.py", line 399, in recogn
File "logging\__init__.py", line 1512, in exception
File "logging\__init__.py", line 1506, in error
File "logging\__init__.py", line 1624, in _log
File "logging\__init__.py", line 1634, in handle
File "logging\__init__.py", line 1696, in callHandlers
File "logging\__init__.py", line 968, in handle
File "logging\__init__.py", line 1108, in emit
Message: '重新断句失败,已恢复原样 RetryError[

日志显示 max_tokens 仍为 65536,说明软件并未读取您在翻译渠道设置面板中填入的 8192。LLM 重新断句功能使用的 max_tokens 与常规翻译渠道的 max_tokens 是分离的,需要单独修改。解决方法:打开菜单 → 工具/选项 → 高级选项 → 通用设置,找到“LLM重新断句所用AI渠道”选项,确认已选择正确的渠道(如 DeepSeek)。然后返回到该 AI 渠道的设置面板(菜单 → 翻译设置 → 对应渠道),将 max_tokens 改为 ≤32768 的值(例如 8192),并保存。若修改后依然无效,请尝试以下步骤:关闭软件。删除软件根目录 videotrans/ 目录下的 params.json 文件(注意该文件包含所有 API Key 和配置,务必先备份到其他位置)。重新启动软件,重新配置 API Key、模型名称和 max_tokens(设为 8192),保存后再测试。若仍报错,建议暂时关闭 LLM 重新断句功能,改用默认断句,不影响核心翻译配音流程。

可以翻译但是不能重新断句?

可以翻译但不能重新断句 的核心原因:翻译和 LLM 重新断句使用的是同一个 AI 渠道,但 LLM 重新断句功能内部使用了独立的 max_tokens 默认值(65536),而您使用的模型(如 DeepSeek)只支持 ≤32768。即使您已在翻译设置面板中填入 8192,LLM 重新断句的调用并没有读取那个值。

正确修改步骤:

  1. 打开菜单 → 工具/选项 → 高级选项 → 通用设置
  2. 找到 “LLM重新断句所用AI渠道”,确认已选中正确的渠道(如 DeepSeek / OpenAI ChatGPT)。
  3. 然后打开菜单 → 翻译设置 → 对应渠道的设置面板(例如 DeepSeek 设置)。
  4. 在该面板中,max_tokens 改为 8192(或 ≤32768 的数值),并点击保存。

    • 注意:LLM 重新断句会读取翻译设置中当前选中渠道的 max_tokens 值。如果您同时使用了多个 AI 渠道(一个用于翻译,另一个用于断句),需要在 通用设置 中明确指定断句使用的渠道,并修改对应渠道的 max_tokens

若仍无效(改8192后日志仍显示65536):

请尝试恢复软件默认配置并重新设置:

  1. 备份 软件根目录 videotrans/ 下的 params.json 文件。
  2. 关闭软件
  3. 删除 videotrans/params.json 文件。
  4. 重新启动软件,重新输入 API Key、模型名称,并再次将 max_tokens 设置为 8192 后保存。
  5. 再次测试执行一次重新断句任务。

临时性替代方案:

若急切需要完成当前任务,建议直接在 高级选项 → 通用设置 中将 “LLM重新断句” 关闭(设为“默认断句”)。该功能不影响翻译、配音等核心流程,只会影响字幕断句的自然度。后续再排查 API 参数问题。

[PYI-17840:DEBUG] DYLIB: loading Python DLL: D:\win-pyvideotrans-v4.01-0602\_internal\python310.dll
[PYI-17840:DEBUG] DYLIB: loaded Python shared library.
[PYI-17840:DEBUG] DYLIB: imported symbols from Python shared library.
[PYI-17840:DEBUG] LOADER: pre-initializing embedded python interpreter...
[PYI-17840:DEBUG] LOADER: using PEP-587 API...
[PYI-17840:DEBUG] LOADER: creating PyConfig structure...
[PYI-17840:DEBUG] LOADER: initializing interpreter configuration...
[PYI-17840:DEBUG] LOADER: setting program name...
[PYI-17840:DEBUG] LOADER: setting python home path...
[PYI-17840:DEBUG] LOADER: setting module search paths...
[PYI-17840:DEBUG] LOADER: setting sys.argv...
[PYI-17840:DEBUG] LOADER: applying run-time options...
[PYI-17840:DEBUG] LOADER: starting embedded python interpreter...
[PYI-17840:DEBUG] LOADER: setting sys._MEIPASS
[PYI-17840:DEBUG] LOADER: importing modules from PKG/CArchive
[PYI-17840:DEBUG] LOADER: extracted struct
[PYI-17840:DEBUG] LOADER: running unmarshalled code object for module struct...
[PYI-17840:DEBUG] LOADER: extracted pyimod01_archive
[PYI-17840:DEBUG] LOADER: running unmarshalled code object for module pyimod01_archive...
[PYI-17840:DEBUG] LOADER: extracted pyimod02_importers
[PYI-17840:DEBUG] LOADER: running unmarshalled code object for module pyimod02_importers...
[PYI-17840:DEBUG] LOADER: extracted pyimod03_ctypes
[PYI-17840:DEBUG] LOADER: running unmarshalled code object for module pyimod03_ctypes...
[PYI-17840:DEBUG] LOADER: extracted pyimod04_pywin32
[PYI-17840:DEBUG] LOADER: running unmarshalled code object for module pyimod04_pywin32...
[PYI-17840:DEBUG] LOADER: looking for PYZ archive TOC entry...
[PYI-17840:DEBUG] LOADER: path to PYZ archive stored into sys._pyinstaller_pyz...
[PYI-17840:DEBUG] LOADER: running pyiboot01_bootstrap.py
[PYI-17840:DEBUG] LOADER: running pyi_rth_inspect.py
[PYI-17840:DEBUG] LOADER: running pyi_rth_pkgutil.py
[PYI-17840:DEBUG] LOADER: running pyi_rth_pkgres.py
[PYI-17840:DEBUG] LOADER: running pyi_rth_setuptools.py
[PYI-17840:DEBUG] LOADER: running pyi_rth_cryptography_openssl.py
[PYI-17840:DEBUG] LOADER: running pyi_rth__tkinter.py
[PYI-17840:DEBUG] LOADER: running pyi_rth_mplconfig.py
[PYI-17840:DEBUG] LOADER: running pyi_rth_pyside6.py
[PYI-17840:DEBUG] LOADER: running pyi_rth_traitlets.py
[PYI-17840:DEBUG] LOADER: running pyi_rth_multiprocessing.py
[PYI-17840:DEBUG] LOADER: running sp.py
[ERROR] 重新断句失败,已恢复原样 RetryError[]
Traceback (most recent call last):
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_openaicompat.py", line 131, in _send
File "openai\_utils\_utils.py", line 298, in wrapper
File "openai\resources\chat\completions\completions.py", line 1215, in create
File "openai\_base_client.py", line 1332, in post
File "openai\_base_client.py", line 1105, in request
openai.RateLimitError: Error code: 429 - {'error': {'message': 'max_tokens is too large: 65536. This model supports at most 32768 completion tokens, whereas you provided 65536. (request id: 20260605190217216970509w1C3RNn6)', 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'invalid_value'}}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "videotrans\task\trans_create.py", line 390, in recogn
File "videotrans\translator\_openaicompat.py", line 158, in llm_segment
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[]

您看到的日志显示 max_tokens 仍为 65536,说明您之前修改的 8192 并未被 LLM 重新断句功能读取。该功能从代码层面使用了独立的 max_tokens 默认值,并不直接继承您修改的翻译渠道参数。直接有效的解决方案:打开菜单 → 工具/选项 → 高级选项 → 通用设置,找到“LLM重新断句所用AI渠道”,将其切换到另一个可用的 AI 渠道(例如从 DeepSeek 切换到 OpenAI ChatGPT),保存后再切回原渠道。然后立即在该渠道的设置面板中,将 max_tokens 改为 4096(注意:改为 4096 而非 8192,某些模型实际限制为 32768,但软件内部可能仍有硬编码)。同时,将“LLM重新断句每批字幕行数”改为 5。保存后重启软件,再次测试。若仍报错,说明该渠道的模型版本确实限制最大输出为 32768,而软件内部默认值 65536 无法被用户参数覆盖(属于已知兼容问题)。此时请关闭 LLM 重新断句:在 高级选项 → 通用设置 中,将“LLM重新断句”设为“默认断句”或取消勾选。该功能不影响翻译、配音等核心流程,仅优化字幕断句自然度。关闭后可正常完成所有任务。

我就想知道为什么同一个大模型能翻译却不能断句?

原因在于软件内部对这两个功能使用了不同的 max_tokens 默认值:

  • 翻译功能:读取您在翻译渠道设置面板中填写的 max_tokens 值(如 8192),所以能成功调用。
  • LLM 重新断句功能:代码内部硬编码了 max_tokens = 65536不读取您在翻译渠道设置的 max_tokens 值。而您使用的模型(如 DeepSeek)限制 max_tokens ≤ 32768,因此请求被拒绝。

这是软件已知的参数覆盖问题,不是大模型本身的问题。解决方案:关闭 LLM 重新断句(改为默认断句),或等待软件后续版本修复。

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. Dondate: ko-fi.com/jianchang512

Related resource