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

140.75**8 Posted at: 45 minutes ago

语音识别阶段出错[Huggingface_ASR(内置)] The expanded size of the tensor (22425) must match the existing size (4268) at non-singleton dimension 1. Target sizes: [128, 22425]. Tensor sizes: [128, 4268]: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 (22425) must match the existing size (4268) at non-singleton dimension 1. Target sizes: [128, 22425]. Tensor sizes: [128, 4268]

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 (22425) must match the existing size (4268) at non-singleton dimension 1. Target sizes: [128, 22425]. Tensor sizes: [128, 4268]: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 (22425) must match the existing size (4268) at non-singleton dimension 1. Target sizes: [128, 22425]. Tensor sizes: [128, 4268]
trk=语音转录
self.cfg.name='E:/DIC-008绝对领域.mkv',
self.cfg.target_dir='D:/pyvideotrans/output',
self.cfg.cache_folder='D:/pyvideotrans/tmp/11296/ebc6e7bd03'
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='ebc6e7bd03', name='E:/DIC-008绝对领域.mkv', dirname='E:/', noextname='DIC-008绝对领域', basename='DIC-008绝对领域.mkv', ext='mkv', target_dir='D:/pyvideotrans/output', cache_folder='D:/pyvideotrans/tmp/11296/ebc6e7bd03', 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/DIC-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/11296/ebc6e7bd03/DIC-008绝对领域-1795558508.6137464.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 44 minutes ago

这是 Huggingface_ASR(内置) 渠道调用 transformers pipeline 时,批处理多个音频切片填充(padding)尺寸不一致导致的内部兼容性错误(Tensor 长度 22425 与 4268 不匹配),与你的视频、语言设置无关,属于该渠道对 kotoba-whisper 模型的适配问题。

解决方案(按顺序尝试):

  1. 换识别渠道(推荐):语音转录界面将 语音识别 改为 faster-whisper(内置),模型选 large-v3(显存不足选 large-v3-turbo),发音语言保持 日语。或改选 openai-whisper(内置) + large-v3,日语效果同样优秀。
  2. 降低切片长度差异对对齐的影响:若坚持使用 Huggingface_ASR 渠道,可打开 菜单-工具/选项-高级选项-语音识别参数,将 最长语音持续(秒) 改为 3、最短语音持续(毫秒) 保持 3000 以下,减小单个切片长度差,重试(不保证一定成功)。
  3. 临时关闭 CUDA 重试:取消勾选 CUDA加速 后再跑一次,排除显存/精度导致的特征长度异常。若仍报同样错误,说明是该模型与当前 transformers 版本的 pipeline bug,请直接放弃该渠道,使用方案 1。
  4. 若想继续用该模型,也可尝试 Audio.cpp(本地) 渠道中对应的 whisper gguf 模型(需 CUDA 或 Vulkan 环境)。

请查阅相关文档:

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