#7095 语音识别阶段出错[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
......
otrans-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=False,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(内置) 渠道在使用 kotoba-tech/kotoba-whisper-v2.0 模型时出现的已知兼容性报错。该模型底层依赖 transformers 的 AutomaticSpeechRecognition pipeline,在处理批量音频切片时,pipeline 内部的 padding 逻辑与模型实际输入长度不匹配,导致张量维度不一致 (3000 vs 3104)。

解决方案如下:

  1. 更换该渠道中的其他日语模型,例如:

    • reazon-research/japanese-wav2vec2-large-rs35kh
    • 或使用通用模型 openai/whisper-large-v3
  2. 如果必须使用 kotoba-whisper-v2.0,请改用其他语音识别渠道:

    • 将语音识别渠道切换为 faster-whisper(内置),模型选择 large-v3-turbo,并指定发音语言为 ja
  3. 另外请注意:Huggingface_ASR(内置) 渠道只要 CUDA 可用就会优先尝试使用 GPU。如果该模型与当前 CUDA/cuDNN 版本不兼容,也可能触发此类底层错误。若更换模型后仍报错,可临时关闭“启用CUDA加速”。

如果你需要继续使用该模型并查明是否与 CUDA 有关,请提供更完整的日志(logs/ 文件夹中最新日志的底部 30 行),但按照上述方案替换渠道后通常可立即恢复处理。

#2 45.12**6 reply at 1 hour ago

[DEBUG] [新进程任务 结束:title='load kotoba-tech/kotoba-whisper-v2.0'],耗时68.51594138145447s
[ERROR] trk=[SpeechToText]语音转录: self.out_format='srt',self.copysrt_rawvideo=False,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
未选 降噪

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

[DEBUG] [job] trk.uuid='2adbc3d2c8'已停止,跳过阶段 SpeechToText trk.cfg=[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
未选 降噪

#3 DeepSeek reply at 1 hour ago

这是 Huggingface_ASR(内置) 渠道的 kotoba-tech/kotoba-whisper-v2.0 模型与 transformers pipeline 批次填充逻辑不兼容导致的张量维度错误。该模型在日语识别时,pipeline 内部按 batch 填充时无法正确对齐输入向量长度,导致 RuntimeError。

建议按以下方案解决:

  1. 更换该渠道下的其他日语模型

    • 将 Huggingface_ASR(内置) 渠道的模型切换为 reazon-research/japanese-wav2vec2-large-rs35khopenai/whisper-large-v3 后再试。
    • 如果模型列表中没有找到上述名称,请确认已下载完整的模型文件,或重新点击模型下拉框选择。
  2. 改用更稳定的识别渠道

    • 将语音识别渠道切换为 faster-whisper(内置),模型选择 large-v3-turbo,发音语言指定为 ja。该渠道对日语支持良好且运行稳定。
    • 若仍需要完全离线,也可使用 openai-whisper(内置) 的 large-v3 模型。
  3. 临时关闭 CUDA 加速(排查底层驱动/cuDNN兼容性)

    • 当前日志显示“已启用CUDA加速”,若更换模型仍然失败,可在主界面取消勾选 启用CUDA加速,再重新执行一次。部分模型与 CUDA 12.8/cuDNN 9.11 组合存在不兼容张量填充的问题。
  4. 如果上述操作均无效

    • 请更换为 faster-whisper 渠道并重新执行,通常可以正常完成日语转录。
    • 若你仍希望保留该模型,请提供 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