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

45.12**6 Posted at: 1 hour ago

语音识别阶段出错[Huggingface_ASR(内置)] The expanded size of the tensor (3104) must match the existing size (3000) at non-singleton dimension 1. Target sizes: [128, 3104]. Tensor sizes: [128, 3000]:Traceback (most recent call last):
File "videotrans\process\stt_pipe.py", line 65, 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
......
eotrans-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

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 (3104) must match the existing size (3000) at non-singleton dimension 1. Target sizes: [128, 3104]. Tensor sizes: [128, 3000]
[SpeechToText]语音转录: self.out_format='srt',self.copysrt_rawvideo=True,self.spk_insert=False
[TaskCfgSTT]
原始输入文件名: C:/Users/1/Desktop/BOBB-442J.mp4,
输出结果保存到文件夹: D:/win-pyvideotrans-v4.11/output/recogn,
临时文件夹: D:/win-pyvideotrans-v4.11/tmp/21316/2adbc3d2c8
未启用CUDA加速
未选 降噪
语音识别:Huggingface_ASR(内置), kotoba-tech/kotoba-whisper-v2.0 断句方式:默认断句
发音语言:ja
未选 降噪


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

3 Replies

#1 DeepSeek reply at 1 hour ago

该错误是 Huggingface_ASR 渠道使用的模型在批量处理音频切片时,音频特征张量长度不一致(3000 vs 3104),导致 RuntimeError。最常见原因是模型文件下载不完整或损坏,也可能是该模型与当前音频切片长度不兼容。

按以下顺序尝试解决:

  1. 重新下载并覆盖模型:根据你的模型 kotoba-tech/kotoba-whisper-v2.0,删除本地 软件目录/models/models--kotoba-tech--kotoba-whisper-v2.0 文件夹,然后重新在软件中运行一次,让软件自动下载;若自动下载失败,请手动从 https://huggingface.co/kotoba-tech/kotoba-whisper-v2.0 下载所有文件,放入上述文件夹内。注意:模型内的文件名不能有括号或重命名。
  2. 更换语音识别渠道:如果重新下载后仍报错,请改用 faster-whisper(内置)openai-whisper(内置) 渠道,模型选择 large-v3-turbolarge-v3,日语效果也很好。
  3. 检查 VAD/切片设置:进入 菜单 → 工具 → 高级选项 → 语音识别参数,将“最长语音持续(秒)”调大(例如 60),“最短语音持续(毫秒)”调大(例如 1000),减少短切片导致的形状不一致。

如果以上方法均无法解决,请提供软件安装目录下 logs/ 文件夹中最新日志文件(复制底部约30行报错信息)以便进一步分析。

请查阅相关文档:

#2 45.12**6 reply at 1 hour ago

原始输入文件名: C:/Users/1/Desktop/BOBB-442J.mp4,
输出结果保存到文件夹: D:/win-pyvideotrans-v4.11/output/recogn,
临时文件夹: D:/win-pyvideotrans-v4.11/tmp/21316/2adbc3d2c8
未启用CUDA加速
未选 降噪
语音识别:Huggingface_ASR(内置), kotoba-tech/kotoba-whisper-v2.0 断句方式:默认断句
发音语言:ja
未选 降噪

File "videotrans\process\stt_pipe.py", line 65, 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.
......
line 35, in _exec
File "videotrans\recognition\_huggingface.py", line 71, in _pipe_asr
File "videotrans\configure\base.py", line 264, in _new_process
videotrans.configure.excepts.VideoTransError: The expanded size of the tensor (3104) must match the existing size (3000) at non-singleton dimension 1. Target sizes: [128, 3104]. Tensor sizes: [128, 3000]:Traceback (most recent call last):
File "videotrans\process\stt_pipe.py", line 65, 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

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 (3104) must match the existing size (3000) at non-singleton dimension 1. Target sizes: [128, 3104]. Tensor sizes: [128, 3000]

#3 DeepSeek reply at 1 hour ago

该报错是模型文件不完整或损坏,导致音频特征张量长度不匹配(3000 与 3104 不一致)。按以下顺序处理:

  1. 删除模型文件夹 D:/win-pyvideotrans-v4.11/models/models--kotoba-tech--kotoba-whisper-v2.0,回到软件重跑,让软件自动重新下载。
  2. 若自动下载仍失败,手动下载该模型所有文件(https://huggingface.co/kotoba-tech/kotoba-whisper-v2.0),放入上述文件夹,确保文件名无括号、无重命名。
  3. 若重试后仍报错,请改用 faster-whisper(内置) 渠道,模型选择 large-v3-turbolarge-v3,日语识别效果好。

请查阅相关文档:

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