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

118.166**8 Posted at: 10 hours ago

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

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

File "E:\output\win-pyvideotrans-v4.20\_internal\transformers\pipelines\base.py", line 1257, in call

outputs = list(final_iterator)

File "E:\output\win-pyvideotrans-v4.20\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "E:\output\win-pyvideotrans-v4.20\_internal\transformers\pipelines\pt_utils.py", line 271, in next

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

File "E:\output\win-pyvideotrans-v4.20\_internal\torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "E:\output\win-pyvideotrans-v4.20\_internal\torch\utils\data\dataloader.py", line 789, in _next_data

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

File "E:\output\win-pyvideotrans-v4.20\_internal\torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "E:\output\win-pyvideotrans-v4.20\_internal\transformers\pipelines\base.py", line 174, in inner

padd

......
e 60, in pipe_asr
File "E:\output\win-pyvideotrans-v4.20\_internal\transformers\pipelines\automatic_speech_recognition.py", line 247, in call

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

File "E:\output\win-pyvideotrans-v4.20\_internal\transformers\pipelines\base.py", line 1257, in call

outputs = list(final_iterator)

File "E:\output\win-pyvideotrans-v4.20\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "E:\output\win-pyvideotrans-v4.20\_internal\transformers\pipelines\pt_utils.py", line 271, in next

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

File "E:\output\win-pyvideotrans-v4.20\_internal\torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "E:\output\win-pyvideotrans-v4.20\_internal\torch\utils\data\dataloader.py", line 789, in _next_data

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

File "E:\output\win-pyvideotrans-v4.20\_internal\torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "E:\output\win-pyvideotrans-v4.20\_internal\transformers\pipelines\base.py", line 174, in inner

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

File "E:\output\win-pyvideotrans-v4.20\_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 (4764) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 4764]
trk=转录翻译
选择音视频文件: E:/output/_video_out/390JNT-042-mp4/390JNT-042.mp4,
输出目录: E:/output/_video_out/390JNT-042-mp4/_video_out/390JNT-042-mp4,
self.cfg.cache_folder='E:/output/win-pyvideotrans-v4.20/tmp/30104/4be3c76e2d'
未选 清理已生成, 未选 启用硬件加速
已选 LLM纠错,LLM纠错每批字幕行数:50, LLM纠错所用AI渠道: DeepSeek
语音识别:Huggingface_ASR(内置), kotoba-tech/kotoba-whisper-v2.0, 发音语言: 日语
最长语音持续(秒): 5s
最短语音持续(毫秒): 2000ms
静音分割持续毫秒: 350ms
语音阈值: 0.5
选择VAD: silero
翻译渠道:DeepSeek,发音语言:日语,目标语言:简体中文
已选 发送完整字幕, AI翻译渠道每批字幕行数:40
video duration:6856216ms
video information:{'video_fps': 29.97002997002997, 'r_frame_rate': 29.97002997002997, 'video_codec_name': 'h264', 'audio_codec_name': 'aac', 'width': 1920, 'height': 1080, 'time': 6856216, 'streams_len': 2, 'streams_audio': 1, 'video_streams': 1, 'color': 'yuv420p'}
self.cfg=TaskCfgVTT(uuid='4be3c76e2d', name='E:/output/_video_out/390JNT-042-mp4/390JNT-042.mp4', dirname='E:/output/_video_out/390JNT-042-mp4', noextname='390JNT-042', basename='390JNT-042.mp4', ext='mp4', target_dir='E:/output/_video_out/390JNT-042-mp4/_video_out/390JNT-042-mp4', cache_folder='E:/output/win-pyvideotrans-v4.20/tmp/30104/4be3c76e2d', is_cuda=False, source_language='日语', source_language_code='ja', source_sub='E:/output/_video_out/390JNT-042-mp4/_video_out/390JNT-042-mp4/ja.srt', source_wav='E:/output/win-pyvideotrans-v4.20/tmp/30104/4be3c76e2d/ja.wav', source_wav_output='E:/output/_video_out/390JNT-042-mp4/_video_out/390JNT-042-mp4/ja.m4a', target_language='简体中文', target_language_code='zh-cn', target_sub='E:/output/_video_out/390JNT-042-mp4/_video_out/390JNT-042-mp4/zh-cn.srt', target_wav='E:/output/win-pyvideotrans-v4.20/tmp/30104/4be3c76e2d/target.wav', target_wav_output='E:/output/_video_out/390JNT-042-mp4/_video_out/390JNT-042-mp4/zh-cn.m4a', translate_type=5, tts_type=0, volume='+0%', pitch='+0Hz', voice_rate='+0%', voice_role='No', voice_autorate=False, video_autorate=False, remove_silent_mid=False, align_sub_audio=True, tts_model_name=None, detect_language='ja', recogn_type=11, model_name='kotoba-tech/kotoba-whisper-v2.0', shibie_audio=None, remove_noise=False, enable_diariz=False, nums_diariz=0, rephrase=True, fix_punc=0, app_mode='tiqu', subtitle_language=None, targetdir_mp4='E:/output/_video_out/390JNT-042-mp4/_video_out/390JNT-042-mp4/390JNT-042.mp4', novoice_mp4='E:/output/win-pyvideotrans-v4.20/tmp/30104/4be3c76e2d/novoice.mp4', is_separate=False, embed_bgm=True, instrument='E:/output/win-pyvideotrans-v4.20/tmp/30104/4be3c76e2d/instrument.wav', vocal='E:/output/win-pyvideotrans-v4.20/tmp/30104/4be3c76e2d/vocal.wav', clear_cache=False, background_music='', subtitle_type=0, only_out_mp4=False, recogn2pass=False, output_srt=0, copysrt_rawvideo=False, loop_backaudio=0, backaudio_volume=0.8, batch=True)


=
system:Windows-10-10.0.19045-SP0
version:v4.20
frozen:True
language:zh_CN
root_dir:E:/output/win-pyvideotrans-v4.20

1 Replies

#1 DeepSeek reply at 10 hours ago

这是 Huggingface_ASR(内置) 渠道在处理不相等长度的音频切片、并将它们批量送入 transformers pipeline 进行补齐(padding)时发生异常而报出的错误:VAD 切出的各段音频长度不一致(一段对应 4764,另一段对应 3000),而该渠道的批处理逻辑在将这些切片 padding 到同一长度时计算有误。这属于 _huggingface.py + transformers pipeline 的内部缺陷,并不是你的参数或视频有问题;知识库中暂无该具体错误的处理条目。

建议按以下顺序规避:

  1. 更换语音识别渠道(最有效)

    • 日语视频的免费推荐方案是:openai-whisper(内置) 搭配 large-v3,或 faster-whisper(内置) 搭配 large-v3,这两种渠道对日语的通用效果都很好,这类 padding 错误不会出现。
    • 其他可选:Audio.cpp 的 haas_asr、Qwen-ASR(内置)、Nemotron-3.5-asr-0.6b(内置)。
    • 更换后务必勾选主界面的 清理已生成 再重试,避免复用上次失败的中间文件。
  2. 若想继续使用 kotoba-whisper-v2.0,可尝试让切片长度更整齐
    在 菜单 → 工具/选项 → 高级选项 → 语音识别参数 中:

    • 最长语音持续(秒) 由 5 调小为 3~4
    • 静音分割持续毫秒 由 350 调大至 600~800
      这样切片长度会更接近统一,降低触发该 padding 报错的概率。调整后勾选 清理已生成 重试。
  3. 仍未解决
    请保留该现象,并前往项目仓库或技术支持渠道反馈此 BUG(注明版本 v4.20、渠道 Huggingface_ASR、模型 kotoba-tech/kotoba-whisper-v2.0、发音语言日语、Windows 预打包版)。

请查阅相关文档:

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