#8490 语音识别阶段出错[Huggingface_ASR(内置)] The expanded size of the tensor (3000) must match the existing size (3401) at non-singleto

2408**d7be Posted at: 2 hours ago

语音识别阶段出错[Huggingface_ASR(内置)] The expanded size of the tensor (3000) must match the existing size (3401) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 3401]:Traceback (most recent call last):
File "videotrans\process\stt_pipe.py", line 61, in pipe_asr
File "D:\Video-Restoration\pyvideotrans-v4.17\_internal\transformers\pipelines\automatic_speech_recognition.py", line 247, in call

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

File "D:\Video-Restoration\pyvideotrans-v4.17\_internal\transformers\pipelines\base.py", line 1257, in call

outputs = list(final_iterator)

File "D:\Video-Restoration\pyvideotrans-v4.17\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "D:\Video-Restoration\pyvideotrans-v4.17\_internal\transformers\pipelines\pt_utils.py", line 271, in next

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

File "D:\Video-Restoration\pyvideotrans-v
......
e "D:\Video-Restoration\pyvideotrans-v4.17\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "D:\Video-Restoration\pyvideotrans-v4.17\_internal\transformers\pipelines\pt_utils.py", line 271, in next

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

File "D:\Video-Restoration\pyvideotrans-v4.17\_internal\torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "D:\Video-Restoration\pyvideotrans-v4.17\_internal\torch\utils\data\dataloader.py", line 789, in _next_data

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

File "D:\Video-Restoration\pyvideotrans-v4.17\_internal\torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "D:\Video-Restoration\pyvideotrans-v4.17\_internal\transformers\pipelines\base.py", line 174, in inner

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

File "D:\Video-Restoration\pyvideotrans-v4.17\_internal\transformers\pipelines\base.py", line 110, in _pad

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

RuntimeError: The expanded size of the tensor (3000) must match the existing size (3401) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 3401]
trk=[SpeechToText]: uuid='db73c32c97', proxy_str=None, cfg=[TaskCfgSTT]
原始输入文件名: D:/Video-Restoration/Video/Restoration/SNOS-400.restored.mp4,
输出结果保存到文件夹: D:/Video-Restoration/pyvideotrans-v4.17/output/recogn,
临时文件夹: D:/Video-Restoration/pyvideotrans-v4.17/tmp/38500/db73c32c97
已启用CUDA加速
未选 降噪
语音识别:Huggingface_ASR(内置), kotoba-tech/kotoba-whisper-v2.0
发音语言:ja
未选 降噪, precent=1, hasend=False, should_recogn=True, should_trans=False, should_dubbing=False, should_hebing=False, out_format='srt', copysrt_rawvideo=True, spk_insert=False


=
system:Windows-10-10.0.26300-SP0
version:v4.17
frozen:True
language:zh_CN
root_dir:D:/Video-Restoration/pyvideotrans-v4.17

1 Replies

#1 DeepSeek reply at 2 hours ago

这不是软件本身的 bug,而是 Huggingface_ASR(内置) 渠道经由 transformers 5.x 的 whisper pipeline 处理时,某段送入模型的音频帧数(3401 帧 ≈ 34 秒)超过了 30 秒的最大上下文长度,因此 pipeline 在批处理 padding 时抛出尺寸不匹配错误。该报错发生在 transformers 库内部,软件层无法直接捕获修正。你使用的 kotoba-tech/kotoba-whisper-v2.0 是日语专用模型。

推荐的规避方案:

  1. 换用更稳定的日语识别渠道(首选,最省事):

    • faster-whisper(内置) + large-v3 模型(日语识别效果好)
    • 或 Nemotron-3.5-asr-0.6b(内置)
  2. 若必须使用 Huggingface_ASR,缩短 VAD 切片:

    • 菜单 → 工具/选项 → 高级选项 → 语音识别参数
    • 将 最长语音持续(秒) 调小为 5
    • 重试前勾选主界面 清理已生成,避免使用上次缓存的错误切片
  3. 可尝试取消 CUDA 加速再重试,排除环境因素。

由于该报错源于依赖库内部,若以上方案仍无法解决,请改用方案 1 更换识别渠道。

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