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

39.172* Posted at: 14 hours ago

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

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

File "E:\AI\Trans-Movie\pyvideotrans\_internal\transformers\pipelines\base.py", line 1248, in call

outputs = list(final_iterator)

File "E:\AI\Trans-Movie\pyvideotrans\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "E:\AI\Trans-Movie\pyvideotrans\_internal\transformers\pipelines\pt_utils.py", line 271, in next

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

File "E:\AI\Trans-Movie\pyvideotrans\_internal\torch\utils\data\dataloader.py
......
\transformers\pipelines\pt_utils.py", line 271, in next

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

File "E:\AI\Trans-Movie\pyvideotrans\_internal\torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "E:\AI\Trans-Movie\pyvideotrans\_internal\torch\utils\data\dataloader.py", line 789, in _next_data

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

File "E:\AI\Trans-Movie\pyvideotrans\_internal\torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "E:\AI\Trans-Movie\pyvideotrans\_internal\transformers\pipelines\base.py", line 173, in inner

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

File "E:\AI\Trans-Movie\pyvideotrans\_internal\transformers\pipelines\base.py", line 109, in _pad

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

RuntimeError: The expanded size of the tensor (3000) must match the existing size (3058) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 3058]
cfg=TaskCfgSTT(uuid='5ca3555bf8', name='E:/AI/movie/OVA1.MP4', dirname='E:/AI/movie', noextname='OVA1', basename='OVA1.MP4', ext='mp4', target_dir='E:/AI/Trans-Movie/pyvideotrans/output/recogn', cache_folder='E:/AI/Trans-Movie/pyvideotrans/tmp/10844/5ca3555bf8', is_cuda=True, source_language=None, source_language_code=None, source_sub=None, source_wav=None, source_wav_output=None, target_language=None, target_language_code=None, target_sub='E:/AI/Trans-Movie/pyvideotrans/output/recogn/OVA1.srt', target_wav=None, target_wav_output=None, detect_language='auto', recogn_type=9, model_name='kotoba-tech/kotoba-whisper-v2.0', shibie_audio='E:/AI/Trans-Movie/pyvideotrans/tmp/10844/5ca3555bf8/OVA1-1785567872.2778037.wav', remove_noise=False, enable_diariz=False, nums_diariz=0, rephrase=0, fix_punc=0)


=
system:Windows-10-10.0.26200-SP0
version:v4.08
frozen:True
language:zh
root_dir:E:/AI/Trans-Movie/pyvideotrans

1 Replies

这是 Huggingface_ASR 渠道在 Transformers Pipeline 内部对音频切片进行批量填充时,因音频长度超过了模型最大输入长度导致的不兼容崩溃,通常与「过长的待识别音频片段」有关。

请依次尝试以下步骤:

  1. 打开 菜单 → 工具 → 高级选项 → 语音识别参数,将「最长语音持续(秒)」调小(例如 10),并开启「Whisper预分割音频?」;如果仍崩溃,再把「最短语音持续(毫秒)」调低(例如 1000)并勾选「合并过短字幕到邻近」。
  2. 你当前使用了 kotoba-tech/kotoba-whisper-v2.0(日语模型),但 detect_language='auto',请在该任务中将「发音语言」/「检测语言」明确选择为 日语(ja),避免模型自动检测时出现不兼容。
  3. 若仍失败,建议先更换为更稳定的日语识别渠道:faster-whisper(内置) + large-v3openai-whisper(内置) + large-v3,或 parakeet日语(内置) 模型。
  4. 如以上都不行,请提供 软件目录/logs/ 下最新日志文件的完整内容,以及你当前使用的功能面板(是“语音转录”还是“翻译视频”),以便进一步定位。

请查阅相关文档:

Post Your Reply
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

Dondate via PayPal

Related resource