#4062 ValueError: The elements of the batch contain different keys. Cannot batch them ({'attention_mask', 'is_last', 'input_fe

52.197* Posted at: 6 hours ago 👁11

Traceback (most recent call last):
File "videotrans\process\stt_fun.py", line 412, in pipe_asr
File "transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "transformers\pipelines\pt_utils.py", line 271, in next

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

File "torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "torch\utils\data\dataloader.py", line 789, in _next_data

data = self._dataset_fetcher.fetch(index)  # may raise StopIteration

File "torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "transformers\pipelines\base.py", line 182, in inner

raise ValueError(

ValueError: The elements of the batch contain different keys. Cannot batch them ({'attention_mask', 'is_last', 'input_features'} != {'attention_mask', 'is_last', 'input_features', 'num_frames'})


=
system:Windows-10-10.0.19045-SP0
version:v3.97
frozen:True
language:zh
root_dir:F:/FanYi/win-pyvideotrans-v3.97

1 Replies

这是由于使用了 FunASR 语音识别渠道时,模型加载或数据处理过程中出现了内部错误。

解决方案:

  1. 切换语音识别渠道:暂时不要使用 “FunASR中文识别” 渠道。建议切换回更稳定的渠道,例如:

    • 对于中文视频:使用 qwen-asr(本地)
    • 对于多语言或英文视频:使用 faster-whisper(本地) 并选择 large-v3 模型。
  2. 检查模型文件:如果你坚持使用 FunASR,此错误可能意味着模型文件下载不完整或损坏。请尝试:

    • 在软件根目录的 models 文件夹中,找到并删除与 FunASR 相关的模型文件夹(例如 models--iic--speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch)。
    • 重新启动软件,在首次使用 FunASR 时让它重新下载模型。
  3. 更新软件:你当前使用的是 v3.97 版本。请考虑升级到最新的 v3.98 版本,该版本可能已修复此问题。下载完整包后覆盖安装。

如果问题依旧,请提供更详细的日志:
如果切换渠道后仍遇到其他错误,请提供软件安装目录下 logs 文件夹中最新日志文件的底部约30行内容。

请查阅相关文档:

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.

Related resource

Similar issues already exist