mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2024-12-29 19:15:04 +08:00
Format code (#409)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
a94c8e3a69
commit
99404baf94
181
app.py
181
app.py
@ -1,6 +1,7 @@
|
||||
import io
|
||||
import os
|
||||
import torch
|
||||
|
||||
# os.system("wget -P cvec/ https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt")
|
||||
import gradio as gr
|
||||
import librosa
|
||||
@ -20,10 +21,10 @@ from infer_pack.models import (
|
||||
)
|
||||
from i18n import I18nAuto
|
||||
|
||||
logging.getLogger('numba').setLevel(logging.WARNING)
|
||||
logging.getLogger('markdown_it').setLevel(logging.WARNING)
|
||||
logging.getLogger('urllib3').setLevel(logging.WARNING)
|
||||
logging.getLogger('matplotlib').setLevel(logging.WARNING)
|
||||
logging.getLogger("numba").setLevel(logging.WARNING)
|
||||
logging.getLogger("markdown_it").setLevel(logging.WARNING)
|
||||
logging.getLogger("urllib3").setLevel(logging.WARNING)
|
||||
logging.getLogger("matplotlib").setLevel(logging.WARNING)
|
||||
|
||||
i18n = I18nAuto()
|
||||
i18n.print()
|
||||
@ -44,7 +45,7 @@ for root, dirs, files in os.walk(index_root, topdown=False):
|
||||
if name.endswith(".index") and "trained" not in name:
|
||||
index_paths.append("%s/%s" % (root, name))
|
||||
|
||||
|
||||
|
||||
def get_vc(sid):
|
||||
global n_spk, tgt_sr, net_g, vc, cpt, version
|
||||
if sid == "" or sid == []:
|
||||
@ -121,7 +122,6 @@ def load_hubert():
|
||||
hubert_model.eval()
|
||||
|
||||
|
||||
|
||||
def vc_single(
|
||||
sid,
|
||||
input_audio_path,
|
||||
@ -144,7 +144,7 @@ def vc_single(
|
||||
try:
|
||||
audio = input_audio_path[1] / 32768.0
|
||||
if len(audio.shape) == 2:
|
||||
audio = np.mean(audio,-1)
|
||||
audio = np.mean(audio, -1)
|
||||
audio = librosa.resample(audio, orig_sr=input_audio_path[0], target_sr=16000)
|
||||
audio_max = np.abs(audio).max() / 0.95
|
||||
if audio_max > 1:
|
||||
@ -212,114 +212,111 @@ app = gr.Blocks()
|
||||
with app:
|
||||
with gr.Tabs():
|
||||
with gr.TabItem("在线demo"):
|
||||
gr.Markdown(value="""
|
||||
gr.Markdown(
|
||||
value="""
|
||||
RVC 在线demo
|
||||
""")
|
||||
"""
|
||||
)
|
||||
sid = gr.Dropdown(label=i18n("推理音色"), choices=sorted(names))
|
||||
with gr.Column():
|
||||
spk_item = gr.Slider(
|
||||
minimum=0,
|
||||
maximum=2333,
|
||||
step=1,
|
||||
label=i18n("请选择说话人id"),
|
||||
value=0,
|
||||
visible=False,
|
||||
interactive=True,
|
||||
)
|
||||
minimum=0,
|
||||
maximum=2333,
|
||||
step=1,
|
||||
label=i18n("请选择说话人id"),
|
||||
value=0,
|
||||
visible=False,
|
||||
interactive=True,
|
||||
)
|
||||
sid.change(
|
||||
fn=get_vc,
|
||||
inputs=[sid],
|
||||
outputs=[spk_item],
|
||||
fn=get_vc,
|
||||
inputs=[sid],
|
||||
outputs=[spk_item],
|
||||
)
|
||||
gr.Markdown(
|
||||
value=i18n("男转女推荐+12key, 女转男推荐-12key, 如果音域爆炸导致音色失真也可以自己调整到合适音域. ")
|
||||
)
|
||||
vc_input3 = gr.Audio(label="上传音频(长度小于90秒)")
|
||||
vc_transform0 = gr.Number(
|
||||
label=i18n("变调(整数, 半音数量, 升八度12降八度-12)"), value=0
|
||||
)
|
||||
vc_transform0 = gr.Number(label=i18n("变调(整数, 半音数量, 升八度12降八度-12)"), value=0)
|
||||
f0method0 = gr.Radio(
|
||||
label=i18n(
|
||||
"选择音高提取算法,输入歌声可用pm提速,harvest低音好但巨慢无比,crepe效果好但吃GPU"
|
||||
),
|
||||
choices=["pm", "harvest", "crepe"],
|
||||
value="pm",
|
||||
interactive=True,
|
||||
)
|
||||
label=i18n("选择音高提取算法,输入歌声可用pm提速,harvest低音好但巨慢无比,crepe效果好但吃GPU"),
|
||||
choices=["pm", "harvest", "crepe"],
|
||||
value="pm",
|
||||
interactive=True,
|
||||
)
|
||||
filter_radius0 = gr.Slider(
|
||||
minimum=0,
|
||||
maximum=7,
|
||||
label=i18n(">=3则使用对harvest音高识别的结果使用中值滤波,数值为滤波半径,使用可以削弱哑音"),
|
||||
value=3,
|
||||
step=1,
|
||||
interactive=True,
|
||||
)
|
||||
minimum=0,
|
||||
maximum=7,
|
||||
label=i18n(">=3则使用对harvest音高识别的结果使用中值滤波,数值为滤波半径,使用可以削弱哑音"),
|
||||
value=3,
|
||||
step=1,
|
||||
interactive=True,
|
||||
)
|
||||
with gr.Column():
|
||||
file_index1 = gr.Textbox(
|
||||
label=i18n("特征检索库文件路径,为空则使用下拉的选择结果"),
|
||||
value="",
|
||||
interactive=False,
|
||||
visible=False
|
||||
)
|
||||
label=i18n("特征检索库文件路径,为空则使用下拉的选择结果"),
|
||||
value="",
|
||||
interactive=False,
|
||||
visible=False,
|
||||
)
|
||||
file_index2 = gr.Dropdown(
|
||||
label=i18n("自动检测index路径,下拉式选择(dropdown)"),
|
||||
choices=sorted(index_paths),
|
||||
interactive=True,
|
||||
)
|
||||
label=i18n("自动检测index路径,下拉式选择(dropdown)"),
|
||||
choices=sorted(index_paths),
|
||||
interactive=True,
|
||||
)
|
||||
index_rate1 = gr.Slider(
|
||||
minimum=0,
|
||||
maximum=1,
|
||||
label=i18n("检索特征占比"),
|
||||
value=0.88,
|
||||
interactive=True,
|
||||
)
|
||||
minimum=0,
|
||||
maximum=1,
|
||||
label=i18n("检索特征占比"),
|
||||
value=0.88,
|
||||
interactive=True,
|
||||
)
|
||||
resample_sr0 = gr.Slider(
|
||||
minimum=0,
|
||||
maximum=48000,
|
||||
label=i18n("后处理重采样至最终采样率,0为不进行重采样"),
|
||||
value=0,
|
||||
step=1,
|
||||
interactive=True,
|
||||
)
|
||||
minimum=0,
|
||||
maximum=48000,
|
||||
label=i18n("后处理重采样至最终采样率,0为不进行重采样"),
|
||||
value=0,
|
||||
step=1,
|
||||
interactive=True,
|
||||
)
|
||||
rms_mix_rate0 = gr.Slider(
|
||||
minimum=0,
|
||||
maximum=1,
|
||||
label=i18n("输入源音量包络替换输出音量包络融合比例,越靠近1越使用输出包络"),
|
||||
value=1,
|
||||
interactive=True,
|
||||
)
|
||||
minimum=0,
|
||||
maximum=1,
|
||||
label=i18n("输入源音量包络替换输出音量包络融合比例,越靠近1越使用输出包络"),
|
||||
value=1,
|
||||
interactive=True,
|
||||
)
|
||||
protect0 = gr.Slider(
|
||||
minimum=0,
|
||||
maximum=0.5,
|
||||
label=i18n(
|
||||
"保护清辅音和呼吸声,防止电音撕裂等artifact,拉满0.5不开启,调低加大保护力度但可能降低索引效果"
|
||||
),
|
||||
value=0.33,
|
||||
step=0.01,
|
||||
interactive=True,
|
||||
)
|
||||
minimum=0,
|
||||
maximum=0.5,
|
||||
label=i18n("保护清辅音和呼吸声,防止电音撕裂等artifact,拉满0.5不开启,调低加大保护力度但可能降低索引效果"),
|
||||
value=0.33,
|
||||
step=0.01,
|
||||
interactive=True,
|
||||
)
|
||||
f0_file = gr.File(label=i18n("F0曲线文件, 可选, 一行一个音高, 代替默认F0及升降调"))
|
||||
but0 = gr.Button(i18n("转换"), variant="primary")
|
||||
vc_output1 = gr.Textbox(label=i18n("输出信息"))
|
||||
vc_output2 = gr.Audio(label=i18n("输出音频(右下角三个点,点了可以下载)"))
|
||||
but0.click(vc_single,
|
||||
[
|
||||
spk_item,
|
||||
vc_input3,
|
||||
vc_transform0,
|
||||
f0_file,
|
||||
f0method0,
|
||||
file_index1,
|
||||
file_index2,
|
||||
# file_big_npy1,
|
||||
index_rate1,
|
||||
filter_radius0,
|
||||
resample_sr0,
|
||||
rms_mix_rate0,
|
||||
protect0,
|
||||
],
|
||||
[vc_output1, vc_output2],
|
||||
)
|
||||
but0.click(
|
||||
vc_single,
|
||||
[
|
||||
spk_item,
|
||||
vc_input3,
|
||||
vc_transform0,
|
||||
f0_file,
|
||||
f0method0,
|
||||
file_index1,
|
||||
file_index2,
|
||||
# file_big_npy1,
|
||||
index_rate1,
|
||||
filter_radius0,
|
||||
resample_sr0,
|
||||
rms_mix_rate0,
|
||||
protect0,
|
||||
],
|
||||
[vc_output1, vc_output2],
|
||||
)
|
||||
|
||||
|
||||
app.launch()
|
||||
|
@ -9,7 +9,7 @@ import datetime
|
||||
hps = utils.get_hparams()
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = hps.gpus.replace("-", ",")
|
||||
n_gpus = len(hps.gpus.split("-"))
|
||||
from random import shuffle,randint
|
||||
from random import shuffle, randint
|
||||
import traceback, json, argparse, itertools, math, torch, pdb
|
||||
|
||||
torch.backends.cudnn.deterministic = False
|
||||
@ -67,9 +67,10 @@ class EpochRecorder:
|
||||
|
||||
def main():
|
||||
n_gpus = torch.cuda.device_count()
|
||||
if torch.cuda.is_available()==False and torch.backends.mps.is_available()==True:n_gpus = 1
|
||||
if torch.cuda.is_available() == False and torch.backends.mps.is_available() == True:
|
||||
n_gpus = 1
|
||||
os.environ["MASTER_ADDR"] = "localhost"
|
||||
os.environ["MASTER_PORT"] = str(randint(20000,55555))
|
||||
os.environ["MASTER_PORT"] = str(randint(20000, 55555))
|
||||
children = []
|
||||
for i in range(n_gpus):
|
||||
subproc = mp.Process(
|
||||
|
Loading…
Reference in New Issue
Block a user