Add files via upload

This commit is contained in:
RVC-Boss 2024-01-26 11:49:33 +08:00 committed by GitHub
parent 52a9009bde
commit 813cf96e50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,12 +1,11 @@
import os import os
import traceback,gradio as gr import traceback,gradio as gr
import logging import logging
from tools.i18n.i18n import I18nAuto from i18n.i18n import I18nAuto
i18n = I18nAuto() i18n = I18nAuto()
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
import librosa import ffmpeg
import soundfile as sf
import torch import torch
import sys import sys
from mdxnet import MDXNetDereverb from mdxnet import MDXNetDereverb
@ -20,8 +19,7 @@ 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 = []
@ -55,17 +53,16 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format
need_reformat = 1 need_reformat = 1
done = 0 done = 0
try: try:
y, sr = librosa.load(inp_path, sr=None) info = ffmpeg.probe(inp_path, cmd="ffprobe")
info = sf.info(inp_path) if (
channels = info.channels info["streams"][0]["channels"] == 2
if channels == 2 and sr == 44100: and info["streams"][0]["sample_rate"] == "44100"
):
need_reformat = 0 need_reformat = 0
pre_fun._path_audio_( pre_fun._path_audio_(
inp_path, save_root_ins, save_root_vocal, format0, is_hp3=is_hp3 inp_path, save_root_ins, save_root_vocal, format0, is_hp3=is_hp3
) )
done = 1 done = 1
else:
need_reformat = 1
except: except:
need_reformat = 1 need_reformat = 1
traceback.print_exc() traceback.print_exc()
@ -74,8 +71,10 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format
os.path.join(os.environ["TEMP"]), os.path.join(os.environ["TEMP"]),
os.path.basename(inp_path), os.path.basename(inp_path),
) )
y_resampled = librosa.resample(y, sr, 44100) os.system(
sf.write(tmp_path, y_resampled, 44100, "PCM_16") "ffmpeg -i %s -vn -acodec pcm_s16le -ac 2 -ar 44100 %s -y"
% (inp_path, tmp_path)
)
inp_path = tmp_path inp_path = tmp_path
try: try:
if done == 0: if done == 0:
@ -116,10 +115,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="RVC WebUI") as app: with gr.Blocks(title="UVR5 WebUI") as app:
gr.Markdown( gr.Markdown(
value= value=
i18n("本软件以MIT协议开源, 作者不对软件具备任何控制力, 使用软件者、传播软件导出的声音者自负全责. <br>如不认可该条款, 则不能使用或引用软件包内任何代码和文件. 详见根目录<b>LICENSE</b>.") "MIT license. https://github.com/Anjok07/ultimatevocalremovergui"
) )
with gr.Tabs(): with gr.Tabs():
with gr.TabItem(i18n("伴奏人声分离&去混响&去回声")): with gr.TabItem(i18n("伴奏人声分离&去混响&去回声")):
@ -144,7 +143,7 @@ with gr.Blocks(title="RVC WebUI") as app:
minimum=0, minimum=0,
maximum=20, maximum=20,
step=1, step=1,
label=i18n("人声提取激进程度"), label="人声提取激进程度",
value=10, value=10,
interactive=True, interactive=True,
visible=False, # 先不开放调整 visible=False, # 先不开放调整
@ -180,7 +179,6 @@ with gr.Blocks(title="RVC 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,
share=is_share, server_port=9873,
server_port=webui_port_uvr5,
quiet=True, quiet=True,
) )