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

141.227**6 Posted at: 54 minutes ago

语音识别阶段出错[Huggingface_ASR(内置)] The expanded size of the tensor (3000) must match the existing size (5337) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 5337]: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
......
deotrans-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 (3000) must match the existing size (5337) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 5337]
[SpeechToText]语音转录: self.out_format='srt',self.copysrt_rawvideo=False,self.spk_insert=True
[TaskCfgSTT]
原始输入文件名: C:/Users/1/Desktop/BOBB-442J.mp4,
输出结果保存到文件夹: D:/win-pyvideotrans-v4.11/output/recogn,
临时文件夹: D:/win-pyvideotrans-v4.11/tmp/8760/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 54 minutes ago

从报错看,这是 Huggingface_ASR(内置) 渠道在批处理语音切片时,音频特征长度不一致导致的 RuntimeError,并非软件本身的 bug。

解决办法(按推荐顺序)

  1. 更换为更稳定的识别渠道:建议使用 openai-whisper(内置) 模型选择 large-v3,或使用 parakeet日语(内置)(仅限日语)。这两个渠道对音频长度兼容性更好,尤其适合日语视频。
  2. 若坚持使用 Huggingface_ASR:可尝试将模型换成 reazon-research/japanese-wav2vec2-large-rs35kh(同为日语专用),减小批处理形状冲突的风险。
  3. 调整切片参数:在 菜单→工具→高级选项→语音识别参数 中,适当增大 最短语音持续(毫秒)(如设为 5000)并减小 最长语音持续(秒)(如设为 10),使切片长度更均匀,避免极端长短差异。
  4. 检查模型完整性:若以上不行,请删除 软件目录/models/models--kotoba-tech--kotoba-whisper-v2.0 文件夹,重新自动下载,避免模型文件不完整引发异常。

如果更换渠道后仍出现异常,请提供 logs/ 下最新的日志文件,以便进一步定位。

请查阅相关文档:

#2 141.227**6 reply at 51 minutes ago

我这就是原地址下载的 。,一直都在出错,到底咋办

#3 DeepSeek reply at 51 minutes ago

问题的核心:Huggingface_ASR(内置) 这一渠道在 v4.12 中因底层 transformers 库的已知兼容性问题,导致不同长度音频切片在批量填充时计算编码维度不一致而崩溃。该问题与模型是否完整下载无关,属于渠道本身缺陷。

解决方案(按优先级):

  1. 放弃该渠道,改用 parakeet日语(内置),该渠道专为日语优化,质量高、无此报错。在主界面“语音识别”渠道下拉框中选择 parakeet日语(内置),模型不必额外选择。
  2. 改用 openai-whisper(内置),模型选 large-v3,通用效果好,但速度偏慢。
  3. 若坚持必须用 Huggingface_ASR(内置),请将模型换成 reazon-research/japanese-wav2vec2-large-rs35kh(同样是日语专用),通常可避开 kotoba-whisper-v2.0 在 v4.12 下的崩溃路径。
  4. 同时建议在 菜单→工具→高级选项→语音识别参数 中,将 最短语音持续(毫秒) 调到 5000最长语音持续(秒) 调到 10,以减少切片长度极端差异,但该操作仅能缓解,不能根治。

如果更换渠道后仍出现任何错误,请提供 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