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

139.202**7 Posted at: 2 hours ago

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

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

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

outputs = list(final_iterator)

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

item = next(self.iterator)

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

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

File "D:\pyvideotrans
......
outputs = list(final_iterator)
File "D:\pyvideotrans-v4.11\win-pyvideotrans-v4.11\_internal\transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

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

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

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

data = self._next_data()

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

return self.collate_fn(data)

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

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

File "D:\pyvideotrans-v4.11\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 (3027) at non-singleton dimension 1. Target sizes: [128, 3000]. Tensor sizes: [128, 3027]
[SpeechToText]语音转录: self.out_format='srt',self.copysrt_rawvideo=True,self.spk_insert=False
[TaskCfgSTT]
原始输入文件名: E:/已翻/新建文件夹/midv-888 はじめて彼女ができたのに隣に住む喪女ニートお姉さんに食べられカラダの相性良すぎて浮気なのに何度もsexしまくった 水卜さくら/MIDV-888 .mp4,
输出结果保存到文件夹: D:/pyvideotrans-v4.11/win-pyvideotrans-v4.11/output/recogn,
临时文件夹: D:/pyvideotrans-v4.11/win-pyvideotrans-v4.11/tmp/13696/9fe6a1f275
已启用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:/pyvideotrans-v4.11/win-pyvideotrans-v4.11

1 Replies

#1 DeepSeek reply at 2 hours ago

导致该报错的核心原因是 Huggingface_ASR 渠道在批量处理音频特征时,张量形状发生不匹配(目标长度 3000 小于实际特征长度 3027),通常是 kotoba-whisper-v2.0 模型文件下载不完整/损坏,或该模型与当前 transformers 版本存在兼容性问题。

解决方案

  1. 优先切换为 faster-whisper(内置) 渠道(默认推荐)

    • 语音识别渠道改为 faster-whisper(内置),模型选择 large-v3-turbo
    • 对日语支持良好,且经过大量验证,稳定性最高
  2. 若必须使用 Huggingface_ASR 渠道,可采取以下措施

    • 删除损坏的模型文件重新下载:删除 软件目录/models/models--kotoba-tech--kotoba-whisper-v2.0 文件夹,让软件重新自动下载;若自动下载持续失败,请手动前往 https://huggingface.co/kotoba-tech/kotoba-whisper-v2.0/tree/main 下载全部文件,并放置到上述文件夹内
    • 切换其他模型:在下拉框中改用 reazon-research/japanese-wav2vec2-large-rs35kh(日语专用)或 openai/whisper-large-v3(通用效果好)尝试
    • 暂时关闭 CUDA 加速:取消勾选 启用CUDA加速,排除 GPU 兼容性干扰
  3. 升级软件版本:当前日志中路径显示为 v4.11,但版本号显示 v4.12,若实际未升级到最新版,请前往官方下载完整包覆盖升级,确保 transformers 等核心依赖为最新修复状态。
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