#2107 单个语音转字幕能识别,多个语音转字幕第二个就报错

205.185* Posted at: 21 hours ago 👁11

语音识别阶段出错:[阿里FunASR中文(本地)] 程序内部错误:expected Tensor as element 1 in argument 0, but got str:
Traceback (most recent call last):
File "videotrans\task\job.py", line 113, in run
File "videotrans\task\_speech2text.py", line 146, in recogn
File "videotrans\recognition\__init__.py", line 227, in run
File "videotrans\recognition\_base.py", line 80, in run
File "videotrans\recognition\_funasr.py", line 60, in _exec
File "funasr\auto\auto_model.py", line 306, in generate

return self.inference_with_vad(input, input_len=input_len, **cfg)

File "funasr\auto\auto_model.py", line 383, in inference_with_vad

res = self.inference(

File "funasr\auto\auto_model.py", line 345, in inference

res = model.inference(**batch, **kwargs)

File "C:\AI\win-pyvideotrans-3.90\_internal\funasr\models\fsmn_vad_streaming\model.py", line 690, in inference

audio_sample = torch.cat((cache["prev_samples"], audio_sample_list[0]))

TypeError: expected Tensor as element 1 in argument 0, but got str


=
system:Windows-10-10.0.22621-SP0
version:v3.90
frozen:True
language:zh
root_dir:C:/AI/win-pyvideotrans-3.90

1 Replies

这个问题是阿里FunASR本地模型在处理多个音频文件时出现的内部错误。根据错误日志,问题出现在FunASR模型的音频样本拼接环节。

核心原因:FunASR在处理第一个音频文件后,缓存状态可能没有正确重置,导致处理第二个文件时数据类型不匹配。

解决方案

  1. 临时解决方案:在“工具箱”中使用“批量语音转字幕”功能时,不要一次性添加太多文件,建议逐个处理或少量处理。
  2. 推荐解决方案:更换语音识别模型

    • 在主界面的“语音识别”区域,将模型从“阿里FunASR中文(本地)”切换为“faster-whisper(本地)”。
    • 选择适合的模型大小(如 mediumlarge-v3),并确保勾选“CUDA加速”(如果有NVIDIA显卡)。
  3. 高级排查:如果必须使用FunASR,请尝试:

    • 检查音频文件格式是否统一(建议统一为WAV或MP3格式)。
    • 在“高级选项”中,将“VAD参数”的“语音阈值”适当调高(如从0.45改为0.5),减少噪音干扰。

如果问题依旧,请提供更详细的音频文件信息(格式、时长),以便进一步分析。

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.

Donate: https://ko-fi.com/jianchang512

Trending Questions