#6640 cannot reshape tensor of 0 elements into shape [-1, 0] because the unspecified dimension size -1 can be any value and is

1.168.**6 Posted at: 1 hour ago

cannot reshape tensor of 0 elements into shape [-1, 0] because the unspecified dimension size -1 can be any value and is ambiguous,Traceback (most recent call last):
File "videotrans\process\omnivoice_tts.py", line 74, in omnivoice_fun
File "E:\dramahandle\win-pyvideotrans-v4.09\_internal\torch\utils\_contextlib.py", line 116, in decorate_context

return func(*args, **kwargs)

File "omnivoice\models\omnivoice.py", line 567, in generate

voice_clone_prompt=voice_clone_prompt,

File "omnivoice\models\omnivoice.py", line 959, in _preprocess_all
File "omnivoice\models\omnivoice.py", line 638, in create_voice_clone_prompt

if waveform.shape[0] > 1:

File "omnivoice\utils\audio.py", line 84, in load_audio

data = torchaudio.functional.resample(

File "E:\dramahandle\win-pyvideotrans-v4.09\_internal\torchaudio\functional\functional.py", line 1530, in resample

resampled = _apply_sinc_resample_kernel(waveform, orig_freq, new_freq, gcd, kernel, width)

Fil
......
nsor of 0 elements into shape [-1, 0] because the unspecified dimension size -1 can be any value and is ambiguous,Traceback (most recent call last):
File "videotrans\process\omnivoice_tts.py", line 74, in omnivoice_fun
File "E:\dramahandle\win-pyvideotrans-v4.09\_internal\torch\utils\_contextlib.py", line 116, in decorate_context

return func(*args, **kwargs)

File "omnivoice\models\omnivoice.py", line 567, in generate

voice_clone_prompt=voice_clone_prompt,

File "omnivoice\models\omnivoice.py", line 959, in _preprocess_all
File "omnivoice\models\omnivoice.py", line 638, in create_voice_clone_prompt

if waveform.shape[0] > 1:

File "omnivoice\utils\audio.py", line 84, in load_audio

data = torchaudio.functional.resample(

File "E:\dramahandle\win-pyvideotrans-v4.09\_internal\torchaudio\functional\functional.py", line 1530, in resample

resampled = _apply_sinc_resample_kernel(waveform, orig_freq, new_freq, gcd, kernel, width)

File "E:\dramahandle\win-pyvideotrans-v4.09\_internal\torchaudio\functional\functional.py", line 1462, in _apply_sinc_resample_kernel

waveform = waveform.view(-1, shape[-1])

RuntimeError: cannot reshape tensor of 0 elements into shape [-1, 0] because the unspecified dimension size -1 can be any value and is ambiguous

cfg=[TaskCfgVTT]当前工作模式: 翻译视频或音频 单视频模式
原始输入文件名: G:/youtube/漫剧/漫剧封面/98.末世:从丧尸开始进化(80集)AI短剧/1.mp4,
输出结果保存到文件夹: G:/youtube/漫剧/漫剧封面/98.末世:从丧尸开始进化(80集)AI短剧/_video_out/1-mp4,
临时文件夹: E:/dramahandle/win-pyvideotrans-v4.09/tmp/33376/9bf5e8a68d
未选 清理已存在
已启用CUDA加速
未选 降噪
已选 识别说话人,最大说话人数量不限制
语音识别:faster-whisper(内置), large-v3-turbo, 发音语言: 简体中文, 断句方式:默认断句
翻译渠道:DeepSeek,原始语言:简体中文,目标语言:英语, 已选 发送完整字幕
配音渠道:OmniVoice(内置), 角色:clone, 配音语言:英语, 已选 二次语音识别
音量:+0%, 语速:+10%, 已选 音频加速, 已选 视频慢速
字幕: 嵌入硬字幕
已选 分离人声与背景声,存在分离后的纯净人声文件,存在分离后的背景声音文件
代理地址:http://127.0.0.1:7897


=
system:Windows-10-10.0.26200-SP0
version:v4.09
frozen:True
language:zh
root_dir:E:/dramahandle/win-pyvideotrans-v4.09

1 Replies

#1 DeepSeek reply at 1 hour ago

核心原因:这是 OmniVoice 配音渠道在 clone 模式下,按字幕时间从原音频中截取参考音频时,某一条字幕对应的音频片段为空(0 个采样点),导致 torchaudio 重采样时报 cannot reshape tensor of 0 elements。最常见原因是某条字幕时间轴过短、结束时间早于开始时间、或截取出的临时音频为 0 字节。

解决方案:

  1. 打开 菜单 → 工具 → 高级选项 → 语音识别参数,设置:

    • 最长语音持续(秒):6-10
    • 最短语音持续(毫秒):3000-4000
    • 勾选 合并过短字幕到邻近
    • 若使用 clone 配音,勾选 Whisper预分割音频
  2. 如果启用了 识别说话人,建议先取消该选项再重试,排查是否因说话人分离导致个别字幕时间轴异常。
  3. 暂时不要使用 LLM重新断句,避免重新切分时间轴后截取到空音频。
  4. 可以先切换到 Edge-TTS 配音角色试跑一次;如果不再报错,则确认是 clone 参考音频片段提取问题。
  5. 若问题仍复现,请检查临时文件夹 E:/dramahandle/win-pyvideotrans-v4.09/tmp/33376/9bf5e8a68d 中对应字幕时段的音频文件是否为 0 字节。另建议将视频路径改为纯英文目录(如 D:/videos/1.mp4)后重试,排除特殊字符导致中间文件写入异常。

如果上述调整后依然报错,请提供 logs/ 目录下最新日志底部约 30 行错误信息。

请查阅相关文档:

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

Dondate via ko-fi.com

Related resource