mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2025-04-06 03:57:44 +08:00
Add files via upload
This commit is contained in:
parent
7c3f34aff6
commit
2d1ddeca42
@ -1,11 +1,12 @@
|
|||||||
import os
|
import os
|
||||||
import traceback,gradio as gr
|
import traceback,gradio as gr
|
||||||
import logging
|
import logging
|
||||||
from i18n.i18n import I18nAuto
|
from tools.i18n.i18n import I18nAuto
|
||||||
i18n = I18nAuto()
|
i18n = I18nAuto()
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
import ffmpeg
|
import librosa
|
||||||
|
import soundfile as sf
|
||||||
import torch
|
import torch
|
||||||
import sys
|
import sys
|
||||||
from mdxnet import MDXNetDereverb
|
from mdxnet import MDXNetDereverb
|
||||||
@ -19,7 +20,8 @@ for name in os.listdir(weight_uvr5_root):
|
|||||||
|
|
||||||
device=sys.argv[1]
|
device=sys.argv[1]
|
||||||
is_half=sys.argv[2]
|
is_half=sys.argv[2]
|
||||||
|
webui_port_uvr5=int(sys.argv[3])
|
||||||
|
is_share=eval(sys.argv[4])
|
||||||
|
|
||||||
def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format0):
|
def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format0):
|
||||||
infos = []
|
infos = []
|
||||||
@ -50,40 +52,32 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format
|
|||||||
paths = [path.name for path in paths]
|
paths = [path.name for path in paths]
|
||||||
for path in paths:
|
for path in paths:
|
||||||
inp_path = os.path.join(inp_root, path)
|
inp_path = os.path.join(inp_root, path)
|
||||||
need_reformat = 1
|
if(os.path.isfile(inp_path)==False):continue
|
||||||
done = 0
|
|
||||||
try:
|
try:
|
||||||
info = ffmpeg.probe(inp_path, cmd="ffprobe")
|
done = 0
|
||||||
if (
|
try:
|
||||||
info["streams"][0]["channels"] == 2
|
y, sr = librosa.load(inp_path, sr=None)
|
||||||
and info["streams"][0]["sample_rate"] == "44100"
|
info = sf.info(inp_path)
|
||||||
):
|
channels = info.channels
|
||||||
need_reformat = 0
|
if channels == 2 and sr == 44100:
|
||||||
pre_fun._path_audio_(
|
need_reformat = 0
|
||||||
inp_path, save_root_ins, save_root_vocal, format0, is_hp3=is_hp3
|
pre_fun._path_audio_(
|
||||||
|
inp_path, save_root_ins, save_root_vocal, format0, is_hp3=is_hp3
|
||||||
|
)
|
||||||
|
done = 1
|
||||||
|
else:
|
||||||
|
need_reformat = 1
|
||||||
|
except:
|
||||||
|
need_reformat = 1
|
||||||
|
traceback.print_exc()
|
||||||
|
if need_reformat == 1:
|
||||||
|
tmp_path = "%s/%s.reformatted.wav" % (
|
||||||
|
os.path.join(os.environ["TEMP"]),
|
||||||
|
os.path.basename(inp_path),
|
||||||
)
|
)
|
||||||
done = 1
|
y_resampled = librosa.resample(y, sr, 44100)
|
||||||
except:
|
sf.write(tmp_path, y_resampled, 44100, "PCM_16")
|
||||||
need_reformat = 1
|
inp_path = tmp_path
|
||||||
traceback.print_exc()
|
|
||||||
if need_reformat == 1:
|
|
||||||
tmp_path = "%s/%s.reformatted.wav" % (
|
|
||||||
os.path.join(os.environ["TEMP"]),
|
|
||||||
os.path.basename(inp_path),
|
|
||||||
)
|
|
||||||
os.system(
|
|
||||||
"ffmpeg -i %s -vn -acodec pcm_s16le -ac 2 -ar 44100 %s -y"
|
|
||||||
% (inp_path, tmp_path)
|
|
||||||
)
|
|
||||||
inp_path = tmp_path
|
|
||||||
try:
|
|
||||||
if done == 0:
|
|
||||||
pre_fun._path_audio_(
|
|
||||||
inp_path, save_root_ins, save_root_vocal, format0
|
|
||||||
)
|
|
||||||
infos.append("%s->Success" % (os.path.basename(inp_path)))
|
|
||||||
yield "\n".join(infos)
|
|
||||||
except:
|
|
||||||
try:
|
try:
|
||||||
if done == 0:
|
if done == 0:
|
||||||
pre_fun._path_audio_(
|
pre_fun._path_audio_(
|
||||||
@ -92,10 +86,21 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format
|
|||||||
infos.append("%s->Success" % (os.path.basename(inp_path)))
|
infos.append("%s->Success" % (os.path.basename(inp_path)))
|
||||||
yield "\n".join(infos)
|
yield "\n".join(infos)
|
||||||
except:
|
except:
|
||||||
infos.append(
|
try:
|
||||||
"%s->%s" % (os.path.basename(inp_path), traceback.format_exc())
|
if done == 0:
|
||||||
)
|
pre_fun._path_audio_(
|
||||||
yield "\n".join(infos)
|
inp_path, save_root_ins, save_root_vocal, format0
|
||||||
|
)
|
||||||
|
infos.append("%s->Success" % (os.path.basename(inp_path)))
|
||||||
|
yield "\n".join(infos)
|
||||||
|
except:
|
||||||
|
infos.append(
|
||||||
|
"%s->%s" % (os.path.basename(inp_path), traceback.format_exc())
|
||||||
|
)
|
||||||
|
yield "\n".join(infos)
|
||||||
|
except:
|
||||||
|
infos.append("Oh my god. %s->%s"%(os.path.basename(inp_path), traceback.format_exc()))
|
||||||
|
yield "\n".join(infos)
|
||||||
except:
|
except:
|
||||||
infos.append(traceback.format_exc())
|
infos.append(traceback.format_exc())
|
||||||
yield "\n".join(infos)
|
yield "\n".join(infos)
|
||||||
@ -115,10 +120,10 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format
|
|||||||
yield "\n".join(infos)
|
yield "\n".join(infos)
|
||||||
|
|
||||||
|
|
||||||
with gr.Blocks(title="UVR5 WebUI") as app:
|
with gr.Blocks(title="RVC WebUI") as app:
|
||||||
gr.Markdown(
|
gr.Markdown(
|
||||||
value=
|
value=
|
||||||
"MIT license. https://github.com/Anjok07/ultimatevocalremovergui"
|
i18n("本软件以MIT协议开源, 作者不对软件具备任何控制力, 使用软件者、传播软件导出的声音者自负全责. <br>如不认可该条款, 则不能使用或引用软件包内任何代码和文件. 详见根目录<b>LICENSE</b>.")
|
||||||
)
|
)
|
||||||
with gr.Tabs():
|
with gr.Tabs():
|
||||||
with gr.TabItem(i18n("伴奏人声分离&去混响&去回声")):
|
with gr.TabItem(i18n("伴奏人声分离&去混响&去回声")):
|
||||||
@ -143,7 +148,7 @@ with gr.Blocks(title="UVR5 WebUI") as app:
|
|||||||
minimum=0,
|
minimum=0,
|
||||||
maximum=20,
|
maximum=20,
|
||||||
step=1,
|
step=1,
|
||||||
label="人声提取激进程度",
|
label=i18n("人声提取激进程度"),
|
||||||
value=10,
|
value=10,
|
||||||
interactive=True,
|
interactive=True,
|
||||||
visible=False, # 先不开放调整
|
visible=False, # 先不开放调整
|
||||||
@ -179,6 +184,7 @@ with gr.Blocks(title="UVR5 WebUI") as app:
|
|||||||
app.queue(concurrency_count=511, max_size=1022).launch(
|
app.queue(concurrency_count=511, max_size=1022).launch(
|
||||||
server_name="0.0.0.0",
|
server_name="0.0.0.0",
|
||||||
inbrowser=True,
|
inbrowser=True,
|
||||||
server_port=9873,
|
share=is_share,
|
||||||
|
server_port=webui_port_uvr5,
|
||||||
quiet=True,
|
quiet=True,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user