mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2026-01-20 02:51:09 +00:00
chore(sync): merge dev into main (#1399)
* Update mdxnet.py * Update modules.py * Rename preprocess.py to vr.py * Add files via upload * deps: add av lib (#1391) * Add files via upload * chore(format): run black on dev (#1398) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: RVC-Boss <129054828+RVC-Boss@users.noreply.github.com> Co-authored-by: Hiroto N <hironow365@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
1fdbb94811
commit
1696c5356b
@@ -1,3 +1,6 @@
|
||||
import os
|
||||
import traceback
|
||||
|
||||
import librosa
|
||||
import numpy as np
|
||||
import av
|
||||
@@ -47,10 +50,14 @@ def audio2(i, o, format, sr):
|
||||
|
||||
|
||||
def load_audio(file, sr):
|
||||
file = (
|
||||
file.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
|
||||
) # 防止小白拷路径头尾带了空格和"和回车
|
||||
if os.path.exists(file) == False:
|
||||
raise RuntimeError(
|
||||
"You input a wrong audio path that does not exists, please fix it!"
|
||||
)
|
||||
try:
|
||||
file = (
|
||||
file.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
|
||||
) # 防止小白拷路径头尾带了空格和"和回车
|
||||
with open(file, "rb") as f:
|
||||
with BytesIO() as out:
|
||||
audio2(f, out, "f32le", sr)
|
||||
@@ -62,5 +69,5 @@ def load_audio(file, sr):
|
||||
audio = np.mean(audio, -1)
|
||||
return librosa.resample(audio, orig_sr=file[0], target_sr=16000)
|
||||
|
||||
except Exception as e:
|
||||
raise RuntimeError(f"Failed to load audio: {e}")
|
||||
except:
|
||||
raise RuntimeError(traceback.format_exc())
|
||||
|
||||
Reference in New Issue
Block a user