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

2a09**73 Posted at: 1 hour ago

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

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

File "D:\win-pyvideotrans-v4.16-1\_internal\transformers\pipelines\base.py", line 1257, in call

outputs = list(final_iterator)

File "D:\win-pyvideotrans-v4.16-1\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "D:\win-pyvideotrans-v4.16-1\_internal\transformers\pipelines\pt_utils.py", line 271, in next

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

File "D:\win-pyvideotrans-v4.16-1\_internal\torch\utils\data\dataloader.py", line 733, in
......
4.16-1\_internal\transformers\pipelines\base.py", line 1257, in call

outputs = list(final_iterator)

File "D:\win-pyvideotrans-v4.16-1\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "D:\win-pyvideotrans-v4.16-1\_internal\transformers\pipelines\pt_utils.py", line 271, in next

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

File "D:\win-pyvideotrans-v4.16-1\_internal\torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "D:\win-pyvideotrans-v4.16-1\_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.16-1\_internal\torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "D:\win-pyvideotrans-v4.16-1\_internal\transformers\pipelines\base.py", line 174, in inner

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

File "D:\win-pyvideotrans-v4.16-1\_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 (3529) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 3529]
trk=[SpeechToText]: uuid='be95973261', proxy_str=None, cfg=[TaskCfgSTT]
原始输入文件名: E:/DownLoad/4/rrr/カリビアンコム叶あん 近親家族 パート2_2.mp4,
输出结果保存到文件夹: D:/win-pyvideotrans-v4.16-1/output/recogn,
临时文件夹: D:/win-pyvideotrans-v4.16-1/tmp/12812/be95973261
已启用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=False, spk_insert=True


=
system:Windows-10-10.0.26100-SP0
version:v4.16
frozen:True
language:zh_CN
root_dir:D:/win-pyvideotrans-v4.16-1

1 Replies

#1 DeepSeek reply at 1 hour ago

这是因为送入模型的单个音频切片过长(3529帧,超过 Whisper 架构上限 3000 帧≈30秒),导致 transformers pipeline 在 padding 对齐时崩溃。

解决方案

  1. 缩短语音切片长度:进入 菜单 → 工具 → 高级选项 → 语音识别参数,把 最长语音持续(秒)(VAD:max speech duration(s)) 改为 3~5,静音分割持续毫秒(VAD: Min silence duration for split(ms)) 设为 300~500,让每个切片不超 30 秒。
  2. 先关闭降噪和说话人识别测试:你当前开启了降噪与识别说话人,这两步会改变音频流长度且对切片处理有影响。建议先取消勾选这两个选项,单独跑一遍确认该渠道正常,再用其它渠道叠加处理。
  3. 日语识别改用更稳定渠道(推荐):

    • openai-whisper(内置) + large-v3:日语通用效果最好,兼容性也优于该渠道。
    • 或 faster-whisper(内置) + large-v3。
      知识库日语专项推荐就是 openai-whisper large-v3,Huggingface_ASR 的日语专用模型(kotoba-whisper-v2.0)对超长/无 VAD 切分的音频兼容性较弱。
  4. 确认使用最新 v4.16 补丁包:若你仅覆盖了 sp.exe,请把补丁包里的 _internal、videotrans 文件夹一并覆盖,并清理 _internal 下所有 __pycache__ 目录后重试。
若调整后仍复现,请提供软件目录 logs/ 中当次日志底部约 30 行信息进一步确认。

请查阅相关文档:

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