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

171.91.**5 Posted at: 11 hours ago

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

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

File "D:\win-pyvideotrans-v4.11\_internal\transformers\pipelines\base.py", line 1245, in call

outputs = list(final_iterator)

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

item = next(self.iterator)

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

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

File "D:\win-pyvideotrans-v4.11\_internal\torch\utils\data\dataloader.py", line 733, in next
......
\transformers\pipelines\automatic_speech_recognition.py", line 244, in call

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

File "D:\win-pyvideotrans-v4.11\_internal\transformers\pipelines\base.py", line 1245, in call

outputs = list(final_iterator)

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

item = next(self.iterator)

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

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

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

data = self._next_data()

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

return self.collate_fn(data)

File "D:\win-pyvideotrans-v4.11\_internal\transformers\pipelines\base.py", line 173, in inner

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

File "D:\win-pyvideotrans-v4.11\_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 (3465) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 3465]
[SpeechToText]语音转录: self.out_format='srt',self.copysrt_rawvideo=True,self.spk_insert=True
[TaskCfgSTT]
原始输入文件名: F:/超爱/URE-137CX/[email protected]4,
输出结果保存到文件夹: D:/BaiduNetdiskDownload/win-pyvideotrans-v4.11/output/recogn,
临时文件夹: D:/win-pyvideotrans-v4.11/tmp/2500/22ff35351a
已启用CUDA加速
未选 降噪
语音识别:Huggingface_ASR(内置), kotoba-tech/kotoba-whisper-v2.0 断句方式:默认断句
发音语言:ja
未选 降噪


=
system:Windows-10-10.0.19045-SP0
version:v4.11
frozen:True
language:zh
root_dir:D:/win-pyvideotrans-v4.11

1 Replies

#1 DeepSeek reply at 11 hours ago

该错误为 transformers 语音识别 pipeline 内部在批处理音频时发生的张量维度不匹配错误,具体原因无法直接确定。可能涉及所选模型 kotoba-tech/kotoba-whisper-v2.0 对音频输入长度受限、模型文件不完整或 VAD 切分参数设置不当。

建议按以下顺序排查:

  1. 重新下载模型:确认 软件目录/models/models--kotoba-tech--kotoba-whisper-v2.0 内文件完整,若自动下载不完整,请手动删除后重新下载(模型下载地址)。
  2. 调整语音识别参数:在 菜单 → 工具 → 高级选项 → 语音识别参数 中,将“最长语音持续(秒)”调小至 10-15 秒,“最短语音持续(毫秒)”调大至 1000 左右,并勾选“合并过短字幕到邻近”,避免产生过长音频片段。
  3. 更换模型:选用 openai/whisper-large-v3zai-org/GLM-ASR-Nano-2512 等兼容性更好的模型测试是否正常。
  4. 关闭 CUDA 加速:若上述无效,可取消勾选 CUDA 加速,改用 CPU 的 float32 数据类型再试。
  5. 提供完整日志:请提供 logs/ 目录下最新日志的完整内容(尤其是报错前后 30 行),以便进一步定位。

请查阅相关文档:

Thinking...
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

Related resource