#5840 The expanded size of the tensor (3000) must match the existing size (3247) at non-singleton dimension 1. Target sizes:

36.163* Posted at: 12 hours ago

The expanded size of the tensor (3000) must match the existing size (3247) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 3247]:Traceback (most recent call last):
File "videotrans\process\_stt_pipe.py", line 97, in pipe_asr
File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\automatic_speech_recognition.py", line 266, in call

return super().__call__(inputs, **kwargs)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\base.py", line 1248, in call

outputs = list(final_iterator)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\pt_utils.py", line 271, in next

processed = self.infer(next(self.iterator), **self.params)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\torch\utils\data\dataloader.py", line 789, in _next_data

data = self._dataset_fetcher.fetch(index)  # may raise StopIteration

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\base.py", line 173, in inner

padded[key] = _pad(items, key, _padding_value, padding_side)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\base.py", line 109, in _pad

tensor[i, : len(item[key][0])] = item[key][0]

RuntimeError: The expanded size of the tensor (3000) must match the existing size (3247) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 3247]

Traceback (most recent call last):
File "videotrans\task\only_one.py", line 46, in run
File "videotrans\task\_stage_recogn.py", line 62, in recogn
File "videotrans\recognition\__init__.py", line 205, in run
File "videotrans\recognition\_base.py", line 91, in run
File "videotrans\recognition\_huggingface.py", line 35, in _exec
File "videotrans\recognition\_huggingface.py", line 59, in _pipe_asr
File "videotrans\configure\base.py", line 272, in _new_process
videotrans.configure.excepts.VideoTransError: The expanded size of the tensor (3000) must match the existing size (3247) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 3247]:Traceback (most recent call last):
File "videotrans\process\_stt_pipe.py", line 97, in pipe_asr
File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\automatic_speech_recognition.py", line 266, in call

return super().__call__(inputs, **kwargs)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\base.py", line 1248, in call

outputs = list(final_iterator)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\pt_utils.py", line 271, in next

processed = self.infer(next(self.iterator), **self.params)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\torch\utils\data\dataloader.py", line 789, in _next_data

data = self._dataset_fetcher.fetch(index)  # may raise StopIteration

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\base.py", line 173, in inner

padded[key] = _pad(items, key, _padding_value, padding_side)

File "D:\下载\下载视频\win-pyvideotrans-v4.05-0711\_internal\transformers\pipelines\base.py", line 109, in _pad

tensor[i, : len(item[key][0])] = item[key][0]

RuntimeError: The expanded size of the tensor (3000) must match the existing size (3247) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 3247]

cfg=[TaskCfgVTT]当前工作模式: 翻译视频或音频 单视频模式
原始输入文件名: D:/下载/下载视频/视频/FC2PPV 3615385.mp4,
输出结果保存到文件夹: D:/下载/下载视频/_video_out/FC2PPV 3615385-mp4,
临时文件夹: D:/下载/下载视频/win-pyvideotrans-v4.05-0711/tmp/11672/e456160589
已选 清理已存在
未选 启用CUDA加速
未选 降噪
语音识别:Huggingface_ASR(本地内置), model_name: kotoba-tech/kotoba-whisper-v2.0, 发音语言: 日语, 断句方式:默认断句
翻译渠道:DeepSeek,原始语言:日语,目标语言:简体中文, 已选 发送完整字幕
未选 配音角色,不进行配音
字幕: 嵌入软字幕
已选 仅输出mp4
代理地址:


=
system:Windows-10-10.0.22631-SP0
version:v4.05
frozen:True
language:zh
root_dir:D:/下载/下载视频/win-pyvideotrans-v4.05-0711

1 Replies

这是 Huggingface_ASR 渠道中 kotoba-tech/kotoba-whisper-v2.0 模型在处理超长音频片段时的 pad 尺寸限制错误。该模型期望每个音频片段的帧数不超过约 3000,但您输入的片段长度达到 3247,导致张量填充失败。

解决方案:

  1. 缩短语音识别时的单个片段时长
    进入 菜单 → 工具 → 高级选项 → 语音识别参数,将 最长语音持续(秒) 设置为 10 或更小(例如 8),并 勾选 Whisper预分割音频(如果之前未勾选请勾选上)。这样能确保每个音频片段不超过模型处理的帧数上限。
  2. 或更换语音识别渠道

    • 日语场景推荐使用 openai-whisper(本地内置) + large-v3 模型,或 faster-whisper(本地内置) + large-v3 模型,它们对长音频的支持更稳定。
    • 如果坚持使用 Huggingface_ASR,请选择 openai/whisper-large-v3 模型(通用性好)而非 kotoba-tech/kotoba-whisper-v2.0
  3. 确保 CUDA 加速已关闭(当前未启用,但若后续启用需注意显存)

修改后重新执行任务即可。

请查阅相关文档:

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 via ko-fi.com

Dondate via PayPal

Related resource