GPT-SoVITS icon indicating copy to clipboard operation
GPT-SoVITS copied to clipboard

Failed to load audio files?

Open Jeru2023 opened this issue 1 year ago • 1 comments

My file path is correct, double checked...

but still getting below error, can someone pls help?

(replica) PS D:\dev\replica\GPT-SoVITS> python webui.py Running on local URL: http://0.0.0.0:9874 "D:\conda_envs\replica\python.exe" tools/slice_audio.py "D:\dev\replica\audio\input" "output\slicer_opt" -34 4000 300 10 500 0.9 0.25 0 4 "D:\conda_envs\replica\python.exe" tools/slice_audio.py "D:\dev\replica\audio\input" "output\slicer_opt" -34 4000 300 10 500 0.9 0.25 1 4 "D:\conda_envs\replica\python.exe" tools/slice_audio.py "D:\dev\replica\audio\input" "output\slicer_opt" -34 4000 300 10 500 0.9 0.25 2 4 "D:\conda_envs\replica\python.exe" tools/slice_audio.py "D:\dev\replica\audio\input" "output\slicer_opt" -34 4000 300 10 500 0.9 0.25 3 4 D:\dev\replica\audio\input\1.wav D:\dev\replica\audio\input\1.wav ->fail-> Traceback (most recent call last): File "D:\dev\replica\GPT-SoVITS\tools\my_utils.py", line 13, in load_audio ffmpeg.input(file, threads=0) File "D:\conda_envs\replica\lib\site-packages\ffmpeg_run.py", line 313, in run process = run_async( File "D:\conda_envs\replica\lib\site-packages\ffmpeg_run.py", line 284, in run_async return subprocess.Popen( File "D:\conda_envs\replica\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "D:\conda_envs\replica\lib\subprocess.py", line 1436, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, OSError: [WinError 1392] 文件或目录损坏且无法读取。

Jeru2023 avatar Jan 27 '24 16:01 Jeru2023

更奇怪的是我把my_utils.py中的代码放到notebook中执行又是可以通过的

Jeru2023 avatar Jan 27 '24 16:01 Jeru2023

我尝试直接运行my_utils.py, 写死了文件输入,没有任何路径分隔符,依然ffmpeg.input这里报错[WinError 1392] 文件或目录损坏且无法读取

import platform,os
import ffmpeg
import numpy as np


def load_audio(file, sr):
    try:
        # https://github.com/openai/whisper/blob/main/whisper/audio.py#L26
        # This launches a subprocess to decode audio while down-mixing and resampling as necessary.
        # Requires the ffmpeg CLI and `ffmpeg-python` package to be installed.
        file = clean_path(file)  # 防止小白拷路径头尾带了空格和"和回车
        print("file in my_util.load_audio ", file)
        file = "1.wav"
        print(os.path.isfile(file))
        out, _ = (
            ffmpeg.input(file, threads=0)
            .output("-", format="f32le", acodec="pcm_f32le", ac=1, ar=sr)
            .run(cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True)
        )
    except Exception as e:
        raise RuntimeError(f"Failed to load audio: {e}")

    return np.frombuffer(out, np.float32).flatten()


def clean_path(path_str):
    if platform.system() == 'Windows':
        print("windows - origin path ", path_str)
        path_str = path_str.replace('/', '\\')
        print("windows - converted path ", path_str)
    return path_str.strip(" ").strip('"').strip("\n").strip('"').strip(" ")

audio = "1.wav"
load_audio(audio,32000)

但是我运行pyaudio是可以播放这个文件的。

Jeru2023 avatar Jan 28 '24 02:01 Jeru2023

终于解决了,从项目根目录删除了ffmpeg, 用以前的环境变量

Jeru2023 avatar Jan 28 '24 03:01 Jeru2023