#5982 语音识别阶段出错[Huggingface_ASR(本地内置)] The expanded size of the tensor (3000) must match the existing size (4611) at non-single

240e:39e* Posted at: 5 hours ago

语音识别阶段出错[Huggingface_ASR(本地内置)] The expanded size of the tensor (3000) must match the existing size (4611) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 4611]:Traceback (most recent call last):
File "videotrans\process\_stt_pipe.py", line 97, in pipe_asr
File "F:\pyvideotrans\win-pyvideotrans-v4.06-0720_20260720_104420\_internal\transformers\pipelines\automatic_speech_recognition.py", line 266, in call

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

File "F:\pyvideotrans\win-pyvideotrans-v4.06-0720_20260720_104420\_internal\transformers\pipelines\base.py", line 1248, in call

outputs = list(final_iterator)

File "F:\pyvideotrans\win-pyvideotrans-v4.06-0720_20260720_104420\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "F:\pyvideotrans\win-pyvideotrans-v4.06-0720_20260720_104420\_internal\transformers\pipelines\pt_utils.py", line 271, in next

processed = self.inf

......
deotrans\win-pyvideotrans-v4.06-0720_20260720_104420\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "F:\pyvideotrans\win-pyvideotrans-v4.06-0720_20260720_104420\_internal\transformers\pipelines\pt_utils.py", line 271, in next

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

File "F:\pyvideotrans\win-pyvideotrans-v4.06-0720_20260720_104420\_internal\torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "F:\pyvideotrans\win-pyvideotrans-v4.06-0720_20260720_104420\_internal\torch\utils\data\dataloader.py", line 789, in _next_data

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

File "F:\pyvideotrans\win-pyvideotrans-v4.06-0720_20260720_104420\_internal\torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "F:\pyvideotrans\win-pyvideotrans-v4.06-0720_20260720_104420\_internal\transformers\pipelines\base.py", line 173, in inner

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

File "F:\pyvideotrans\win-pyvideotrans-v4.06-0720_20260720_104420\_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 (4611) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 4611]
cfg=[TaskCfgVTT]当前工作模式: 转录并翻译字幕
原始输入文件名: F:/123.mp4,
输出结果保存到文件夹: F:/123.mp4,
临时文件夹: F:/pyvideotrans/win-pyvideotrans-v4.06-0720_20260720_104420/tmp/19256/12b4f99489
已选 清理已存在
已选 启用CUDA加速
未选 降噪
语音识别:Huggingface_ASR(本地内置), model_name: kotoba-tech/kotoba-whisper-v2.0, 发音语言: 日语, 断句方式:默认断句
翻译渠道:DeepSeek,原始语言:日语,目标语言:简体中文, 已选 发送完整字幕
已选 将生成的字幕复制到视频目录下
输出字幕格式: 单字幕
代理地址:http://127.0.0.1:7897


=
system:Windows-10-10.0.22631-SP0
version:v4.06
frozen:True
language:zh
root_dir:F:/pyvideotrans/win-pyvideotrans-v4.06-0720_20260720_104420

1 Replies

这个错误是因为 Huggingface ASR 模型(kotoba-whisper-v2.0)在处理较长的音频片段时,内部 padding 长度与实际特征长度不匹配导致的。常见原因是音频片段超过模型允许的最大输入长度(默认可能约 30 秒)。

解决方法:

  1. 缩短音频切片长度:打开 菜单 → 工具/选项 → 高级选项 → 语音识别参数,将 最长语音持续(秒) 设为 15 或更小(比如 10)。
  2. 更换 ASR 渠道:Huggingface_ASR 对其他模型的兼容性有限,建议改用 faster-whisper(本地内置) + large-v3 模型,对日语支持良好。
  3. 尝试不启用 CUDA 加速:如果以上无效,可临时取消勾选 CUDA 加速,用 CPU 运行该模型(速度较慢但可能绕过 padding 问题)。

请查阅相关文档:

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