Make Pre-Commit-Hook Exit 0 While Using Ruff Check (#2427)

Modified gradio Layout
Refactor WebUI half-precision and GPU detection logic
main
XXXXRT666 2 months ago committed by GitHub
parent 2ff2cf5ba1
commit 05d44215f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -8,7 +8,7 @@ repos:
# Run the linter.
- id: ruff
types_or: [ python, pyi ]
args: [ --fix ]
args: [ --fix , "--exit-zero" ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi ]

@ -1,30 +1,32 @@
import sys
import os
import re
import sys
import torch,re
import torch
from tools.i18n.i18n import I18nAuto
from tools.i18n.i18n import I18nAuto, scan_language_list
i18n = I18nAuto(language=os.environ.get("language", "Auto"))
pretrained_sovits_name = {
"v1":"GPT_SoVITS/pretrained_models/s2G488k.pth",
"v2":"GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth",
"v3":"GPT_SoVITS/pretrained_models/s2Gv3.pth",###v3v4还要检查vocoder算了。。。
"v4":"GPT_SoVITS/pretrained_models/gsv-v4-pretrained/s2Gv4.pth",
"v2Pro":"GPT_SoVITS/pretrained_models/v2Pro/s2Gv2Pro.pth",
"v2ProPlus":"GPT_SoVITS/pretrained_models/v2Pro/s2Gv2ProPlus.pth",
"v1": "GPT_SoVITS/pretrained_models/s2G488k.pth",
"v2": "GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth",
"v3": "GPT_SoVITS/pretrained_models/s2Gv3.pth", ###v3v4还要检查vocoder算了。。。
"v4": "GPT_SoVITS/pretrained_models/gsv-v4-pretrained/s2Gv4.pth",
"v2Pro": "GPT_SoVITS/pretrained_models/v2Pro/s2Gv2Pro.pth",
"v2ProPlus": "GPT_SoVITS/pretrained_models/v2Pro/s2Gv2ProPlus.pth",
}
pretrained_gpt_name = {
"v1":"GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt",
"v2":"GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt",
"v3":"GPT_SoVITS/pretrained_models/s1v3.ckpt",
"v4":"GPT_SoVITS/pretrained_models/s1v3.ckpt",
"v2Pro":"GPT_SoVITS/pretrained_models/s1v3.ckpt",
"v2ProPlus":"GPT_SoVITS/pretrained_models/s1v3.ckpt",
"v1": "GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt",
"v2": "GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt",
"v3": "GPT_SoVITS/pretrained_models/s1v3.ckpt",
"v4": "GPT_SoVITS/pretrained_models/s1v3.ckpt",
"v2Pro": "GPT_SoVITS/pretrained_models/s1v3.ckpt",
"v2ProPlus": "GPT_SoVITS/pretrained_models/s1v3.ckpt",
}
name2sovits_path={
name2sovits_path = {
# i18n("不训练直接推v1底模"): "GPT_SoVITS/pretrained_models/s2G488k.pth",
i18n("不训练直接推v2底模"): "GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth",
# i18n("不训练直接推v3底模"): "GPT_SoVITS/pretrained_models/s2Gv3.pth",
@ -32,29 +34,47 @@ name2sovits_path={
i18n("不训练直接推v2Pro底模"): "GPT_SoVITS/pretrained_models/v2Pro/s2Gv2Pro.pth",
i18n("不训练直接推v2ProPlus底模"): "GPT_SoVITS/pretrained_models/v2Pro/s2Gv2ProPlus.pth",
}
name2gpt_path={
name2gpt_path = {
# i18n("不训练直接推v1底模"):"GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt",
i18n("不训练直接推v2底模"):"GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt",
i18n("不训练直接推v3底模"):"GPT_SoVITS/pretrained_models/s1v3.ckpt",
i18n(
"不训练直接推v2底模"
): "GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt",
i18n("不训练直接推v3底模"): "GPT_SoVITS/pretrained_models/s1v3.ckpt",
}
SoVITS_weight_root = ["SoVITS_weights", "SoVITS_weights_v2", "SoVITS_weights_v3", "SoVITS_weights_v4", "SoVITS_weights_v2Pro", "SoVITS_weights_v2ProPlus"]
GPT_weight_root = ["GPT_weights", "GPT_weights_v2", "GPT_weights_v3", "GPT_weights_v4", "GPT_weights_v2Pro", "GPT_weights_v2ProPlus"]
SoVITS_weight_version2root={
"v1":"SoVITS_weights",
"v2":"SoVITS_weights_v2",
"v3":"SoVITS_weights_v3",
"v4":"SoVITS_weights_v4",
"v2Pro":"SoVITS_weights_v2Pro",
"v2ProPlus":"SoVITS_weights_v2ProPlus",
SoVITS_weight_root = [
"SoVITS_weights",
"SoVITS_weights_v2",
"SoVITS_weights_v3",
"SoVITS_weights_v4",
"SoVITS_weights_v2Pro",
"SoVITS_weights_v2ProPlus",
]
GPT_weight_root = [
"GPT_weights",
"GPT_weights_v2",
"GPT_weights_v3",
"GPT_weights_v4",
"GPT_weights_v2Pro",
"GPT_weights_v2ProPlus",
]
SoVITS_weight_version2root = {
"v1": "SoVITS_weights",
"v2": "SoVITS_weights_v2",
"v3": "SoVITS_weights_v3",
"v4": "SoVITS_weights_v4",
"v2Pro": "SoVITS_weights_v2Pro",
"v2ProPlus": "SoVITS_weights_v2ProPlus",
}
GPT_weight_version2root={
"v1":"GPT_weights",
"v2":"GPT_weights_v2",
"v3":"GPT_weights_v3",
"v4":"GPT_weights_v4",
"v2Pro":"GPT_weights_v2Pro",
"v2ProPlus":"GPT_weights_v2ProPlus",
GPT_weight_version2root = {
"v1": "GPT_weights",
"v2": "GPT_weights_v2",
"v3": "GPT_weights_v3",
"v4": "GPT_weights_v4",
"v2Pro": "GPT_weights_v2Pro",
"v2ProPlus": "GPT_weights_v2ProPlus",
}
def custom_sort_key(s):
# 使用正则表达式提取字符串中的数字部分和非数字部分
parts = re.split("(\d+)", s)
@ -62,27 +82,37 @@ def custom_sort_key(s):
parts = [int(part) if part.isdigit() else part for part in parts]
return parts
def get_weights_names():
SoVITS_names = []
for key in name2sovits_path:
if os.path.exists(name2sovits_path[key]):SoVITS_names.append(key)
if os.path.exists(name2sovits_path[key]):
SoVITS_names.append(key)
for path in SoVITS_weight_root:
if not os.path.exists(path):continue
if not os.path.exists(path):
continue
for name in os.listdir(path):
if name.endswith(".pth"):
SoVITS_names.append("%s/%s" % (path, name))
if not SoVITS_names:
SoVITS_names = [""]
GPT_names = []
for key in name2gpt_path:
if os.path.exists(name2gpt_path[key]):GPT_names.append(key)
if os.path.exists(name2gpt_path[key]):
GPT_names.append(key)
for path in GPT_weight_root:
if not os.path.exists(path):continue
if not os.path.exists(path):
continue
for name in os.listdir(path):
if name.endswith(".ckpt"):
GPT_names.append("%s/%s" % (path, name))
SoVITS_names=sorted(SoVITS_names, key=custom_sort_key)
GPT_names=sorted(GPT_names, key=custom_sort_key)
SoVITS_names = sorted(SoVITS_names, key=custom_sort_key)
GPT_names = sorted(GPT_names, key=custom_sort_key)
if not GPT_names:
GPT_names = [""]
return SoVITS_names, GPT_names
def change_choices():
SoVITS_names, GPT_names = get_weights_names()
return {"choices": SoVITS_names, "__type__": "update"}, {
@ -106,10 +136,6 @@ pretrained_gpt_path = "GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=
exp_root = "logs"
python_exec = sys.executable or "python"
if torch.cuda.is_available():
infer_device = "cuda"
else:
infer_device = "cpu"
webui_port_main = 9874
webui_port_uvr5 = 9873
@ -118,20 +144,55 @@ webui_port_subfix = 9871
api_port = 9880
if infer_device == "cuda":
gpu_name = torch.cuda.get_device_name(0)
if (
("16" in gpu_name and "V100" not in gpu_name.upper())
or "P40" in gpu_name.upper()
or "P10" in gpu_name.upper()
or "1060" in gpu_name
or "1070" in gpu_name
or "1080" in gpu_name
):
is_half = False
if infer_device == "cpu":
is_half = False
def get_device_dtype_sm(idx: int) -> tuple[torch.device, torch.dtype, float, float]:
cpu = torch.device("cpu")
cuda = torch.device(f"cuda:{idx}")
if not torch.cuda.is_available():
return cpu, torch.float32, 0.0, 0.0
device_idx = idx
capability = torch.cuda.get_device_capability(device_idx)
name = torch.cuda.get_device_name(device_idx)
mem_bytes = torch.cuda.get_device_properties(device_idx).total_memory
mem_gb = mem_bytes / (1024**3) + 0.4
major, minor = capability
sm_version = major + minor / 10.0
is_16_series = bool(re.search(r"16\d{2}", name))
if mem_gb < 4:
return cpu, torch.float32, 0.0, 0.0
if (sm_version >= 7.0 and sm_version != 7.5) or (5.3 <= sm_version <= 6.0):
if is_16_series and sm_version == 7.5:
return cuda, torch.float32, sm_version, mem_gb # 16系卡除外
else:
return cuda, torch.float16, sm_version, mem_gb
return cpu, torch.float32, 0.0, 0.0
IS_GPU = True
GPU_INFOS: list[str] = []
GPU_INDEX: set[int] = set()
GPU_COUNT = torch.cuda.device_count()
CPU_INFO: str = "0\tCPU " + i18n("CPU训练,较慢")
tmp: list[tuple[torch.device, torch.dtype, float, float]] = []
memset: set[float] = set()
for i in range(max(GPU_COUNT, 1)):
tmp.append(get_device_dtype_sm(i))
for j in tmp:
device = j[0]
memset.add(j[3])
if device.type != "cpu":
GPU_INFOS.append(f"{device.index}\t{torch.cuda.get_device_name(device.index)}")
GPU_INDEX.add(device.index)
if not GPU_INFOS:
IS_GPU = False
GPU_INFOS.append(CPU_INFO)
GPU_INDEX.add(0)
infer_device = max(tmp, key=lambda x: (x[2], x[3]))[0]
is_half = any(dtype == torch.float16 for _, dtype, _, _ in tmp)
class Config:

@ -1,6 +1,7 @@
import os
import sys
os.environ["version"] = version="v2Pro"
os.environ["version"] = version = "v2Pro"
now_dir = os.getcwd()
sys.path.insert(0, now_dir)
import warnings
@ -8,7 +9,6 @@ import warnings
warnings.filterwarnings("ignore")
import json
import platform
import re
import shutil
import signal
@ -59,16 +59,23 @@ for site_packages_root in site_packages_roots:
import shutil
import subprocess
from subprocess import Popen
from tools.i18n.i18n import I18nAuto, scan_language_list
language = sys.argv[-1] if sys.argv[-1] in scan_language_list() else "Auto"
os.environ["language"] = language
i18n = I18nAuto(language=language)
from multiprocessing import cpu_count
from config import (
GPU_INDEX,
GPU_INFOS,
IS_GPU,
exp_root,
infer_device,
is_half,
is_share,
memset,
python_exec,
webui_port_infer_tts,
webui_port_main,
@ -76,8 +83,6 @@ from config import (
webui_port_uvr5,
)
from tools import my_utils
from multiprocessing import cpu_count
from tools.my_utils import check_details, check_for_existance
# os.environ['PYTORCH_ENABLE_MPS_FALLBACK'] = '1' # 当遇到mps不支持的步骤时使用cpu
@ -91,56 +96,10 @@ import gradio as gr
n_cpu = cpu_count()
ngpu = torch.cuda.device_count()
gpu_infos = []
mem = []
if_gpu_ok = False
# 判断是否有能用来训练和加速推理的N卡
ok_gpu_keywords = {
"10",
"16",
"20",
"30",
"40",
"A2",
"A3",
"A4",
"P4",
"A50",
"500",
"A60",
"70",
"80",
"90",
"M4",
"T4",
"TITAN",
"L4",
"4060",
"H",
"600",
"506",
"507",
"508",
"509",
}
set_gpu_numbers = set()
if torch.cuda.is_available() or ngpu != 0:
for i in range(ngpu):
gpu_name = torch.cuda.get_device_name(i)
if any(value in gpu_name.upper() for value in ok_gpu_keywords):
# A10#A100#V100#A40#P40#M40#K80#A4500
if_gpu_ok = True # 至少有一张能用的N卡
gpu_infos.append("%s\t%s" % (i, gpu_name))
set_gpu_numbers.add(i)
mem.append(int(torch.cuda.get_device_properties(i).total_memory / 1024 / 1024 / 1024 + 0.4))
# # 判断是否支持mps加速
# if torch.backends.mps.is_available():
# if_gpu_ok = True
# gpu_infos.append("%s\t%s" % ("0", "Apple GPU"))
# mem.append(psutil.virtual_memory().total/ 1024 / 1024 / 1024) # 实测使用系统内存作为显存不会爆显存
set_gpu_numbers = GPU_INDEX
gpu_infos = GPU_INFOS
mem = memset
is_gpu_ok = IS_GPU
v3v4set = {"v3", "v4"}
@ -157,34 +116,12 @@ def set_default():
default_batch_size_s1, \
if_force_ckpt
if_force_ckpt = False
if if_gpu_ok and len(gpu_infos) > 0:
gpu_info = "\n".join(gpu_infos)
if is_gpu_ok:
minmem = min(mem)
# if version == "v3" and minmem < 14:
# # API读取不到共享显存,直接填充确认
# try:
# torch.zeros((1024,1024,1024,14),dtype=torch.int8,device="cuda")
# torch.cuda.empty_cache()
# minmem = 14
# except RuntimeError as _:
# # 强制梯度检查只需要12G显存
# if minmem >= 12 :
# if_force_ckpt = True
# minmem = 14
# else:
# try:
# torch.zeros((1024,1024,1024,12),dtype=torch.int8,device="cuda")
# torch.cuda.empty_cache()
# if_force_ckpt = True
# minmem = 14
# except RuntimeError as _:
# print("显存不足以开启V3训练")
default_batch_size = minmem // 2 if version not in v3v4set else minmem // 8
default_batch_size_s1 = minmem // 2
else:
gpu_info = "%s\t%s" % ("0", "CPU")
gpu_infos.append("%s\t%s" % ("0", "CPU"))
set_gpu_numbers.add(0)
default_batch_size = default_batch_size_s1 = int(psutil.virtual_memory().total / 1024 / 1024 / 1024 / 4)
if version not in v3v4set:
default_sovits_epoch = 8
@ -204,8 +141,8 @@ def set_default():
set_default()
gpus = "-".join([i[0] for i in gpu_infos])
default_gpu_numbers = str(sorted(list(set_gpu_numbers))[0])
gpus = "-".join(map(str, GPU_INDEX))
default_gpu_numbers = infer_device.index
def fix_gpu_number(input): # 将越界的number强制改到界内
@ -227,7 +164,8 @@ def fix_gpu_numbers(inputs):
return inputs
from config import pretrained_sovits_name,pretrained_gpt_name
from config import pretrained_gpt_name, pretrained_sovits_name
def check_pretrained_is_exist(version):
pretrained_model_list = (
@ -243,13 +181,25 @@ def check_pretrained_is_exist(version):
_ += f"\n {i}"
if _:
print("warning: ", i18n("以下模型不存在:") + _)
check_pretrained_is_exist(version)
for key in pretrained_sovits_name.keys():
if os.path.exists(pretrained_sovits_name[key])==False:pretrained_sovits_name[key]=""
if os.path.exists(pretrained_sovits_name[key]) == False:
pretrained_sovits_name[key] = ""
for key in pretrained_gpt_name.keys():
if os.path.exists(pretrained_gpt_name[key])==False:pretrained_gpt_name[key]=""
if os.path.exists(pretrained_gpt_name[key]) == False:
pretrained_gpt_name[key] = ""
from config import (
GPT_weight_root,
GPT_weight_version2root,
SoVITS_weight_root,
SoVITS_weight_version2root,
change_choices,
get_weights_names,
)
from config import SoVITS_weight_root,GPT_weight_root,get_weights_names,change_choices,SoVITS_weight_version2root,GPT_weight_version2root
for root in SoVITS_weight_root + GPT_weight_root:
os.makedirs(root, exist_ok=True)
SoVITS_names, GPT_names = get_weights_names()
@ -556,7 +506,11 @@ def open1Ba(
):
global p_train_SoVITS
if p_train_SoVITS == None:
config_file="GPT_SoVITS/configs/s2.json" if version not in {"v2Pro","v2ProPlus"}else f"GPT_SoVITS/configs/s2{version}.json"
config_file = (
"GPT_SoVITS/configs/s2.json"
if version not in {"v2Pro", "v2ProPlus"}
else f"GPT_SoVITS/configs/s2{version}.json"
)
with open(config_file) as f:
data = f.read()
data = json.loads(data)
@ -586,7 +540,7 @@ def open1Ba(
tmp_config_path = "%s/tmp_s2.json" % tmp
with open(tmp_config_path, "w") as f:
f.write(json.dumps(data))
if version in ["v1", "v2","v2Pro","v2ProPlus"]:
if version in ["v1", "v2", "v2Pro", "v2ProPlus"]:
cmd = '"%s" -s GPT_SoVITS/s2_train.py --config "%s"' % (python_exec, tmp_config_path)
else:
cmd = '"%s" -s GPT_SoVITS/s2_train_v3_lora.py --config "%s"' % (python_exec, tmp_config_path)
@ -907,10 +861,13 @@ def close1a():
{"__type__": "update", "visible": False},
)
sv_path="GPT_SoVITS\pretrained_models\sv\pretrained_eres2netv2w24s4ep4.ckpt"
sv_path = "GPT_SoVITS\pretrained_models\sv\pretrained_eres2netv2w24s4ep4.ckpt"
ps1b = []
process_name_1b = i18n("语音自监督特征提取")
def open1b(version,inp_text, inp_wav_dir, exp_name, gpu_numbers, ssl_pretrained_dir):
def open1b(version, inp_text, inp_wav_dir, exp_name, gpu_numbers, ssl_pretrained_dir):
global ps1b
inp_text = my_utils.clean_path(inp_text)
inp_wav_dir = my_utils.clean_path(inp_wav_dir)
@ -949,7 +906,7 @@ def open1b(version,inp_text, inp_wav_dir, exp_name, gpu_numbers, ssl_pretrained_
for p in ps1b:
p.wait()
ps1b = []
if "Pro"in version:
if "Pro" in version:
for i_part in range(all_parts):
config.update(
{
@ -999,14 +956,18 @@ ps1c = []
process_name_1c = i18n("语义Token提取")
def open1c(version,inp_text,inp_wav_dir, exp_name, gpu_numbers, pretrained_s2G_path):
def open1c(version, inp_text, inp_wav_dir, exp_name, gpu_numbers, pretrained_s2G_path):
global ps1c
inp_text = my_utils.clean_path(inp_text)
if check_for_existance([inp_text, inp_wav_dir], is_dataset_processing=True):
check_details([inp_text, inp_wav_dir], is_dataset_processing=True)
if ps1c == []:
opt_dir = "%s/%s" % (exp_root, exp_name)
config_file="GPT_SoVITS/configs/s2.json" if version not in {"v2Pro","v2ProPlus"}else f"GPT_SoVITS/configs/s2{version}.json"
config_file = (
"GPT_SoVITS/configs/s2.json"
if version not in {"v2Pro", "v2ProPlus"}
else f"GPT_SoVITS/configs/s2{version}.json"
)
config = {
"inp_text": inp_text,
"exp_name": exp_name,
@ -1183,7 +1144,7 @@ def open1abc(
)
for p in ps1abc:
p.wait()
ps1abc=[]
ps1abc = []
if "Pro" in version:
for i_part in range(all_parts):
config.update(
@ -1211,7 +1172,11 @@ def open1abc(
if os.path.exists(path_semantic) == False or (
os.path.exists(path_semantic) == True and os.path.getsize(path_semantic) < 31
):
config_file = "GPT_SoVITS/configs/s2.json" if version not in {"v2Pro", "v2ProPlus"} else f"GPT_SoVITS/configs/s2{version}.json"
config_file = (
"GPT_SoVITS/configs/s2.json"
if version not in {"v2Pro", "v2ProPlus"}
else f"GPT_SoVITS/configs/s2{version}.json"
)
config = {
"inp_text": inp_text,
"exp_name": exp_name,
@ -1337,26 +1302,39 @@ def sync(text):
with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
gr.Markdown(
value=i18n("本软件以MIT协议开源, 作者不对软件具备任何控制力, 使用软件者、传播软件导出的声音者自负全责.")
+ i18n("如不认可该条款, 则不能使用或引用软件包内任何代码和文件. 详见根目录LICENSE.")+ "<br>"+i18n("中文教程文档") + ": " + "https://www.yuque.com/baicaigongchang1145haoyuangong/ib3g1e")
+ i18n("如不认可该条款, 则不能使用或引用软件包内任何代码和文件. 详见根目录LICENSE.")
+ "<br>"
+ i18n("中文教程文档")
+ ": "
+ "https://www.yuque.com/baicaigongchang1145haoyuangong/ib3g1e"
)
with gr.Tabs():
with gr.TabItem("0-" + i18n("前置数据集获取工具")): # 提前随机切片防止uvr5爆内存->uvr5->slicer->asr->打标
gr.Markdown(value="0a-" + i18n("UVR5人声伴奏分离&去混响去延迟工具"))
with gr.Accordion(label="0a-" + i18n("UVR5人声伴奏分离&去混响去延迟工具")):
with gr.Row():
with gr.Column(scale=3):
with gr.Row():
uvr5_info = gr.Textbox(label=process_info(process_name_uvr5, "info"))
open_uvr5 = gr.Button(value=process_info(process_name_uvr5, "open"), variant="primary", visible=True)
close_uvr5 = gr.Button(value=process_info(process_name_uvr5, "close"), variant="primary", visible=False)
open_uvr5 = gr.Button(
value=process_info(process_name_uvr5, "open"), variant="primary", visible=True
)
close_uvr5 = gr.Button(
value=process_info(process_name_uvr5, "close"), variant="primary", visible=False
)
gr.Markdown(value="0b-" + i18n("语音切分工具"))
with gr.Accordion(label="0b-" + i18n("语音切分工具")):
with gr.Row():
with gr.Column(scale=3):
with gr.Row():
slice_inp_path = gr.Textbox(label=i18n("音频自动切分输入路径,可文件可文件夹"), value="")
slice_opt_root = gr.Textbox(label=i18n("切分后的子音频的输出根目录"), value="output/slicer_opt")
slice_opt_root = gr.Textbox(
label=i18n("切分后的子音频的输出根目录"), value="output/slicer_opt"
)
with gr.Row():
threshold = gr.Textbox(label=i18n("threshold:音量小于这个值视作静音的备选切割点"), value="-34")
threshold = gr.Textbox(
label=i18n("threshold:音量小于这个值视作静音的备选切割点"), value="-34"
)
min_length = gr.Textbox(
label=i18n("min_length:每段最小多长,如果第一段太短一直和后面段连起来直到超过这个值"),
value="4000",
@ -1386,7 +1364,12 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
)
with gr.Row():
n_process = gr.Slider(
minimum=1, maximum=n_cpu, step=1, label=i18n("切割使用的进程数"), value=4, interactive=True
minimum=1,
maximum=n_cpu,
step=1,
label=i18n("切割使用的进程数"),
value=4,
interactive=True,
)
slicer_info = gr.Textbox(label=process_info(process_name_slice, "info"))
open_slicer_button = gr.Button(
@ -1411,14 +1394,16 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
value=process_info(process_name_denoise, "close"), variant="primary", visible=False
)
gr.Markdown(value="0c-" + i18n("语音识别工具"))
with gr.Accordion(label="0c-" + i18n("语音识别工具")):
with gr.Row():
with gr.Column(scale=3):
with gr.Row():
asr_inp_dir = gr.Textbox(
label=i18n("输入文件夹路径"), value="D:\\GPT-SoVITS\\raw\\xxx", interactive=True
)
asr_opt_dir = gr.Textbox(label=i18n("输出文件夹路径"), value="output/asr_opt", interactive=True)
asr_opt_dir = gr.Textbox(
label=i18n("输出文件夹路径"), value="output/asr_opt", interactive=True
)
with gr.Row():
asr_model = gr.Dropdown(
label=i18n("ASR 模型"),
@ -1466,7 +1451,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
asr_model.change(change_size_choices, [asr_model], [asr_size])
asr_model.change(change_precision_choices, [asr_model], [asr_precision])
gr.Markdown(value="0d-" + i18n("语音文本校对标注工具"))
with gr.Accordion(label="0d-" + i18n("语音文本校对标注工具")):
with gr.Row():
with gr.Column(scale=3):
with gr.Row():
@ -1476,7 +1461,9 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
interactive=True,
)
label_info = gr.Textbox(label=process_info(process_name_subfix, "info"))
open_label = gr.Button(value=process_info(process_name_subfix, "open"), variant="primary", visible=True)
open_label = gr.Button(
value=process_info(process_name_subfix, "open"), variant="primary", visible=True
)
close_label = gr.Button(
value=process_info(process_name_subfix, "close"), variant="primary", visible=False
)
@ -1487,39 +1474,58 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
close_uvr5.click(change_uvr5, [], [uvr5_info, open_uvr5, close_uvr5])
with gr.TabItem(i18n("1-GPT-SoVITS-TTS")):
with gr.Accordion(i18n("微调模型信息")):
with gr.Row():
with gr.Row(equal_height=True):
exp_name = gr.Textbox(
label=i18n("*实验/模型名"),
value="xxx",
interactive=True,
scale=3,
)
gpu_info_box = gr.Textbox(
label=i18n("显卡信息"),
value=gpu_info,
visible=True,
interactive=False,
scale=5,
)
version_checkbox = gr.Radio(
label=i18n("训练模型的版本"),
value=version,
choices=["v1", "v2", "v4", "v2Pro", "v2ProPlus"],
scale=5,
)
with gr.Accordion(label=i18n("预训练模型路径"), open=False):
with gr.Row():
exp_name = gr.Textbox(label=i18n("*实验/模型名"), value="xxx", interactive=True,scale=3,)
gpu_info = gr.Textbox(label=i18n("显卡信息"), value=gpu_info, visible=True, interactive=False,scale=5,)
version_checkbox = gr.Radio(label=i18n("训练模型的版本"), value=version, choices=["v1","v2", "v4", "v2Pro", "v2ProPlus"],scale=5,)
# version_checkbox = gr.Radio(label=i18n("训练模型的版本"), value=version, choices=["v2", "v4", "v2Pro", "v2ProPlus", "v2ProMax"],scale=5,)
with gr.Row(equal_height=True):
pretrained_s1 = gr.Textbox(
label=i18n("预训练GPT模型路径"),
value=pretrained_gpt_name[version],
interactive=True,
lines=1,
max_lines=1,
scale=3,
)
pretrained_s2G = gr.Textbox(
label=i18n("预训练SoVITS-G模型路径"),
value=pretrained_sovits_name[version],
interactive=True,
lines=2,
max_lines=3,
lines=1,
max_lines=1,
scale=5,
)
pretrained_s2D = gr.Textbox(
label=i18n("预训练SoVITS-D模型路径"),
value=pretrained_sovits_name[version].replace("s2G", "s2D"),
interactive=True,
lines=2,
max_lines=3,
scale=5,
)
pretrained_s1 = gr.Textbox(
label=i18n("预训练GPT模型路径"),
value=pretrained_gpt_name[version],
interactive=True,
lines=2,
max_lines=3,
lines=1,
max_lines=1,
scale=5,
)
with gr.TabItem("1A-" + i18n("训练集格式化工具")):
gr.Markdown(value=i18n("输出logs/实验名目录下应有23456开头的文件和文件夹"))
with gr.Accordion(label=i18n("输出logs/实验名目录下应有23456开头的文件和文件夹")):
with gr.Row():
with gr.Row():
inp_text = gr.Textbox(
@ -1539,7 +1545,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
scale=10,
)
gr.Markdown(value="1Aa-" + process_name_1a)
with gr.Accordion(label="1Aa-" + process_name_1a):
with gr.Row():
with gr.Row():
gpu_numbers1a = gr.Textbox(
@ -1564,7 +1570,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
with gr.Row():
info1a = gr.Textbox(label=process_info(process_name_1a, "info"))
gr.Markdown(value="1Ab-" + process_name_1b)
with gr.Accordion(label="1Ab-" + process_name_1b):
with gr.Row():
with gr.Row():
gpu_numbers1Ba = gr.Textbox(
@ -1589,7 +1595,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
with gr.Row():
info1b = gr.Textbox(label=process_info(process_name_1b, "info"))
gr.Markdown(value="1Ac-" + process_name_1c)
with gr.Accordion(label="1Ac-" + process_name_1c):
with gr.Row():
with gr.Row():
gpu_numbers1c = gr.Textbox(
@ -1614,7 +1620,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
with gr.Row():
info1c = gr.Textbox(label=process_info(process_name_1c, "info"))
gr.Markdown(value="1Aabc-" + process_name_1abc)
with gr.Accordion(label="1Aabc-" + process_name_1abc):
with gr.Row():
with gr.Row():
button1abc_open = gr.Button(
@ -1665,12 +1671,14 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
button1a_close.click(close1a, [], [info1a, button1a_open, button1a_close])
button1b_open.click(
open1b,
[version_checkbox,inp_text, inp_wav_dir, exp_name, gpu_numbers1Ba, cnhubert_base_dir],
[version_checkbox, inp_text, inp_wav_dir, exp_name, gpu_numbers1Ba, cnhubert_base_dir],
[info1b, button1b_open, button1b_close],
)
button1b_close.click(close1b, [], [info1b, button1b_open, button1b_close])
button1c_open.click(
open1c, [version_checkbox,inp_text, inp_wav_dir,exp_name, gpu_numbers1c, pretrained_s2G], [info1c, button1c_open, button1c_close]
open1c,
[version_checkbox, inp_text, inp_wav_dir, exp_name, gpu_numbers1c, pretrained_s2G],
[info1c, button1c_open, button1c_close],
)
button1c_close.click(close1c, [], [info1c, button1c_open, button1c_close])
button1abc_open.click(
@ -1692,7 +1700,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
button1abc_close.click(close1abc, [], [info1abc, button1abc_open, button1abc_close])
with gr.TabItem("1B-" + i18n("微调训练")):
gr.Markdown(value="1Ba-" + i18n("SoVITS 训练: 模型权重文件在 SoVITS_weights/"))
with gr.Accordion(label="1Ba-" + i18n("SoVITS 训练: 模型权重文件在 SoVITS_weights/")):
with gr.Row():
with gr.Column():
with gr.Row():
@ -1758,7 +1766,9 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
) # 只有V3s2可以用
with gr.Row():
gpu_numbers1Ba = gr.Textbox(
label=i18n("GPU卡号以-分割,每个卡号一个进程"), value="%s" % (gpus), interactive=True
label=i18n("GPU卡号以-分割,每个卡号一个进程"),
value="%s" % (gpus),
interactive=True,
)
with gr.Row():
with gr.Row():
@ -1770,7 +1780,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
)
with gr.Row():
info1Ba = gr.Textbox(label=process_info(process_name_sovits, "info"))
gr.Markdown(value="1Bb-" + i18n("GPT 训练: 模型权重文件在 GPT_weights/"))
with gr.Accordion(label="1Bb-" + i18n("GPT 训练: 模型权重文件在 GPT_weights/")):
with gr.Row():
with gr.Column():
with gr.Row():
@ -1821,7 +1831,9 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
)
with gr.Row():
gpu_numbers1Bb = gr.Textbox(
label=i18n("GPU卡号以-分割,每个卡号一个进程"), value="%s" % (gpus), interactive=True
label=i18n("GPU卡号以-分割,每个卡号一个进程"),
value="%s" % (gpus),
interactive=True,
)
with gr.Row():
with gr.Row():
@ -1844,6 +1856,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
)
)
with gr.Row():
with gr.Column(scale=2):
with gr.Row():
GPT_dropdown = gr.Dropdown(
label=i18n("GPT模型列表"),
@ -1857,24 +1870,26 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
value=SoVITS_names[0],
interactive=True,
)
with gr.Column(scale=2):
with gr.Row():
gpu_number_1C = gr.Textbox(label=i18n("GPU卡号,只能填1个整数"), value=gpus, interactive=True)
gpu_number_1C = gr.Textbox(
label=i18n("GPU卡号,只能填1个整数"), value=gpus, interactive=True
)
refresh_button = gr.Button(i18n("刷新模型路径"), variant="primary")
refresh_button.click(fn=change_choices, inputs=[], outputs=[SoVITS_dropdown, GPT_dropdown])
with gr.Row():
with gr.Row(equal_height=True):
with gr.Row():
batched_infer_enabled = gr.Checkbox(
label=i18n("启用并行推理版本"), value=False, interactive=True, show_label=True
)
with gr.Row():
open_tts = gr.Button(
value=process_info(process_name_tts, "open"), variant="primary", visible=True
)
close_tts = gr.Button(
value=process_info(process_name_tts, "close"), variant="primary", visible=False
)
with gr.Row():
tts_info = gr.Textbox(label=process_info(process_name_tts, "info"))
with gr.Column():
tts_info = gr.Textbox(label=process_info(process_name_tts, "info"), scale=2)
open_tts.click(
change_tts_inference,
[

Loading…
Cancel
Save