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

43.207**5 Posted at: 12 hours ago

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

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

File "D:\pyvideotrans\_internal\transformers\pipelines\base.py", line 1257, in call

outputs = list(final_iterator)

File "D:\pyvideotrans\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "D:\pyvideotrans\_internal\transformers\pipelines\pt_utils.py", line 271, in next

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

File "D:\pyvideotrans\_internal\torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "D:\pyvideotrans\_internal\torch\utils\data\dataloader.py", line 789, in _next_data

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

File "D:\pyvideotrans\_internal\torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "D:\pyvideotrans\_internal\transformers\pipelines\base.py", line 174, in inner

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

File "D:\pyvideotrans\_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 (57488) must match the existing size (3000) at non-singleton dimension 1. Target sizes: [128, 57488]. Tensor sizes: [128, 3000]

Traceback (most recent call last):

File "videotrans\task\job.py", line 35, in run

File "videotrans\task\job.py", line 98, in process_task

File "videotrans\task\speech2text.py", line 142, in recogn

File "videotrans\recognition\__init__.py", line 178, in run

File "videotrans\recognition\_base.py", line 101, in run

File "videotrans\recognition\_huggingface.py", line 34, in _exec

File "videotrans\recognition\_huggingface.py", line 70, in _pipe_asr

File "videotrans\configure\base.py", line 300, in _new_process

videotrans.configure.excepts.VideoTransError: The expanded size of the tensor (57488) must match the existing size (3000) at non-singleton dimension 1. Target sizes: [128, 57488]. Tensor sizes: [128, 3000]:Traceback (most recent call last):
File "videotrans\process\stt_pipe.py", line 61, in pipe_asr
File "D:\pyvideotrans\_internal\transformers\pipelines\automatic_speech_recognition.py", line 247, in call

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

File "D:\pyvideotrans\_internal\transformers\pipelines\base.py", line 1257, in call

outputs = list(final_iterator)

File "D:\pyvideotrans\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "D:\pyvideotrans\_internal\transformers\pipelines\pt_utils.py", line 271, in next

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

File "D:\pyvideotrans\_internal\torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "D:\pyvideotrans\_internal\torch\utils\data\dataloader.py", line 789, in _next_data

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

File "D:\pyvideotrans\_internal\torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "D:\pyvideotrans\_internal\transformers\pipelines\base.py", line 174, in inner

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

File "D:\pyvideotrans\_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 (57488) must match the existing size (3000) at non-singleton dimension 1. Target sizes: [128, 57488]. Tensor sizes: [128, 3000]
trk=语音转录
self.cfg.name='D:/+FETI-008.wmv',
self.cfg.target_dir='D:/pyvideotrans/output',
self.cfg.cache_folder='D:/pyvideotrans/tmp/11184/b8621901f9'
self.cfg.is_cuda=True
语音识别:Huggingface_ASR(内置), kotoba-tech/kotoba-whisper-v2.0, 发音语言: ja
最长语音持续(秒): 5s
最短语音持续(毫秒): 3000ms
静音分割持续毫秒: 600ms
语音阈值: 0.45
选择VAD: silero
输出格式: srt
中日韩字幕单行字符数:15, 其他语言字幕单行字符数:40
self.cfg=TaskCfgSTT(uuid='b8621901f9', name='D:/+FETI-008.wmv', dirname='D:/', noextname='+FETI-008', basename='+FETI-008.wmv', ext='wmv', target_dir='D:/pyvideotrans/output', cache_folder='D:/pyvideotrans/tmp/11184/b8621901f9', is_cuda=True, source_language='', source_language_code='', source_sub=None, source_wav=None, source_wav_output=None, target_language='', target_language_code='', target_sub='D:/pyvideotrans/output/+FETI-008.srt', target_wav=None, target_wav_output=None, detect_language='ja', recogn_type=8, model_name='kotoba-tech/kotoba-whisper-v2.0', shibie_audio='D:/pyvideotrans/tmp/11184/b8621901f9/+FETI-008-1795474837.6924894.wav', remove_noise=False, enable_diariz=False, nums_diariz=0, rephrase=False, fix_punc=0)


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

1 Replies

#1 DeepSeek reply at 12 hours ago

这是一个推理层(transformers Pipeline)的维度拼接错误,而非显存不足:kotoba-tech/kotoba-whisper-v2.0 属于 Whisper 架构,其特征提取器会把每个音频切片固定补齐到 3000 帧(≈30 秒),但本次送入 pipeline 的某批数据中混入了长达 57488 帧的未切分长音频,_pad() 试图把 3000 帧的张量塞进 57488 帧的容器里,直接抛出 RuntimeError。也就是说,该模型在当前 Huggingface_ASR(内置) 渠道下与 VAD 切片结果的批处理存在兼容性问题,知识库中无针对此模型该报错的专门说明。

按以下顺序处理:

  1. 换渠道识别日语(最快能跑通)
    日语识别请改用 faster-whisper(内置) + large-v3(或 large-v3-turbo)模型;知识库对日语的首选同样是 openai-whisper / faster-whisper 的 large-v3,kotoba-whisper-v2.0 仅作为备选。
    若坚持用该模型,可再试 openai-whisper(内置) 渠道(同为 Whisper 家族、走不同推理路径,出错概率更低)。
  2. 若仍要用 Huggingface_ASR 渠道,先排除切片参数极端值
    你当前设置:最长语音持续 5s、最短语音持续 3000ms、静音分割 600ms。请先改回默认值验证:

    • 最长语音持续(秒):5 → 10
    • 最短语音持续(毫秒):3000 → 1000
    • 取消勾选 降噪(如有勾选),避免切片被进一步切割成极短/极长片段
      改完重试前务必勾选 清理已生成,否则会复用上次的音频缓存。
  3. 确认模型文件完整
    该模型的正确存放位置是 软件目录/models/models--kotoba-tech--kotoba-whisper-v2.0。若自动下载曾被中断(这也是大量 Unexpected size / padding 类错误的间接诱因),请删除该文件夹后重新识别一次,让它重新下载;或按手动下载方式从 https://huggingface.co/kotoba-tech/kotoba-whisper-v2.0/tree/main 下载全部文件覆盖进去(注意同名文件不要被浏览器重命名为 model(2).safetensors)。
  4. 临时关闭 CUDA 交叉验证
    在语音转录界面取消勾选 CUDA加速 再跑一次;若 CPU 下正常、CUDA 下报错,则属于该模型在本机 CUDA 环境下的推理兼容问题,仍建议回退到第 1 条方案。

如果按第 1 条换成 faster-whisper 后恢复正常,则无需进一步排查——该报错本身就是 kotoba 模型经 transformers pipeline 批推理时的固有缺陷。若换渠道后仍报同类维度错误,请提供 D:/pyvideotrans/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