From 06429f78cddc2cb914f9f6adfb4a2face525c2c2 Mon Sep 17 00:00:00 2001 From: aoguai <1340219674@qq.com> Date: Thu, 27 Jun 2024 22:45:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E5=A4=9A=E4=BD=99=20m?= =?UTF-8?q?y=5Futils.py=20(#1189)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GPT_SoVITS/inference_webui.py | 2 +- GPT_SoVITS/my_utils.py | 21 --------------------- GPT_SoVITS/onnx_export.py | 2 +- 3 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 GPT_SoVITS/my_utils.py diff --git a/GPT_SoVITS/inference_webui.py b/GPT_SoVITS/inference_webui.py index 4dc1040d..44c6d0eb 100644 --- a/GPT_SoVITS/inference_webui.py +++ b/GPT_SoVITS/inference_webui.py @@ -65,7 +65,7 @@ from text import cleaned_text_to_sequence from text.cleaner import clean_text from time import time as ttime from module.mel_processing import spectrogram_torch -from my_utils import load_audio +from tools.my_utils import load_audio from tools.i18n.i18n import I18nAuto i18n = I18nAuto() diff --git a/GPT_SoVITS/my_utils.py b/GPT_SoVITS/my_utils.py deleted file mode 100644 index 776939dd..00000000 --- a/GPT_SoVITS/my_utils.py +++ /dev/null @@ -1,21 +0,0 @@ -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 = ( - file.strip(" ").strip('"').strip("\n").strip('"').strip(" ") - ) # 防止小白拷路径头尾带了空格和"和回车 - 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() diff --git a/GPT_SoVITS/onnx_export.py b/GPT_SoVITS/onnx_export.py index b82e987f..ab457d75 100644 --- a/GPT_SoVITS/onnx_export.py +++ b/GPT_SoVITS/onnx_export.py @@ -9,7 +9,7 @@ cnhubert.cnhubert_base_path=cnhubert_base_path ssl_model = cnhubert.get_model() from text import cleaned_text_to_sequence import soundfile -from my_utils import load_audio +from tools.my_utils import load_audio import os import json