From 05d44215f183428fecb3852d90fd6b3e538b4511 Mon Sep 17 00:00:00 2001
From: XXXXRT666 <157766680+XXXXRT666@users.noreply.github.com>
Date: Thu, 5 Jun 2025 10:46:05 +0800
Subject: [PATCH] Make Pre-Commit-Hook Exit 0 While Using Ruff Check (#2427)
Modified gradio Layout
Refactor WebUI half-precision and GPU detection logic
---
.pre-commit-config.yaml | 2 +-
config.py | 179 +++++---
webui.py | 951 ++++++++++++++++++++--------------------
3 files changed, 604 insertions(+), 528 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 2434e74..17293ce 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -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 ]
diff --git a/config.py b/config.py
index 5eaa87a..81cda36 100644
--- a/config.py
+++ b/config.py
@@ -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:
diff --git a/webui.py b/webui.py
index eb60847..f899508 100644
--- a/webui.py
+++ b/webui.py
@@ -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)
+ 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,64 +1302,82 @@ def sync(text):
with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
gr.Markdown(
value=i18n("本软件以MIT协议开源, 作者不对软件具备任何控制力, 使用软件者、传播软件导出的声音者自负全责.")
- + i18n("如不认可该条款, 则不能使用或引用软件包内任何代码和文件. 详见根目录LICENSE.")+ "
"+i18n("中文教程文档") + ": " + "https://www.yuque.com/baicaigongchang1145haoyuangong/ib3g1e")
+ + i18n("如不认可该条款, 则不能使用或引用软件包内任何代码和文件. 详见根目录LICENSE.")
+ + "
"
+ + 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.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)
+ 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
+ )
- gr.Markdown(value="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")
- with gr.Row():
- threshold = gr.Textbox(label=i18n("threshold:音量小于这个值视作静音的备选切割点"), value="-34")
- min_length = gr.Textbox(
- label=i18n("min_length:每段最小多长,如果第一段太短一直和后面段连起来直到超过这个值"),
- value="4000",
- )
- min_interval = gr.Textbox(label=i18n("min_interval:最短切割间隔"), value="300")
- hop_size = gr.Textbox(
- label=i18n("hop_size:怎么算音量曲线,越小精度越大计算量越高(不是精度越大效果越好)"),
- value="10",
- )
- max_sil_kept = gr.Textbox(label=i18n("max_sil_kept:切完后静音最多留多长"), value="500")
- with gr.Row():
- _max = gr.Slider(
- minimum=0,
- maximum=1,
- step=0.05,
- label=i18n("max:归一化后最大值多少"),
- value=0.9,
- interactive=True,
- )
- alpha = gr.Slider(
- minimum=0,
- maximum=1,
- step=0.05,
- label=i18n("alpha_mix:混多少比例归一化后音频进来"),
- value=0.25,
- interactive=True,
- )
- with gr.Row():
- n_process = gr.Slider(
- 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(
- value=process_info(process_name_slice, "open"), variant="primary", visible=True
- )
- close_slicer_button = gr.Button(
- value=process_info(process_name_slice, "close"), variant="primary", visible=False
- )
+ 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"
+ )
+ with gr.Row():
+ threshold = gr.Textbox(
+ label=i18n("threshold:音量小于这个值视作静音的备选切割点"), value="-34"
+ )
+ min_length = gr.Textbox(
+ label=i18n("min_length:每段最小多长,如果第一段太短一直和后面段连起来直到超过这个值"),
+ value="4000",
+ )
+ min_interval = gr.Textbox(label=i18n("min_interval:最短切割间隔"), value="300")
+ hop_size = gr.Textbox(
+ label=i18n("hop_size:怎么算音量曲线,越小精度越大计算量越高(不是精度越大效果越好)"),
+ value="10",
+ )
+ max_sil_kept = gr.Textbox(label=i18n("max_sil_kept:切完后静音最多留多长"), value="500")
+ with gr.Row():
+ _max = gr.Slider(
+ minimum=0,
+ maximum=1,
+ step=0.05,
+ label=i18n("max:归一化后最大值多少"),
+ value=0.9,
+ interactive=True,
+ )
+ alpha = gr.Slider(
+ minimum=0,
+ maximum=1,
+ step=0.05,
+ label=i18n("alpha_mix:混多少比例归一化后音频进来"),
+ value=0.25,
+ interactive=True,
+ )
+ with gr.Row():
+ n_process = gr.Slider(
+ 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(
+ value=process_info(process_name_slice, "open"), variant="primary", visible=True
+ )
+ close_slicer_button = gr.Button(
+ value=process_info(process_name_slice, "close"), variant="primary", visible=False
+ )
# gr.Markdown(value="0bb-" + i18n("语音降噪工具")+i18n("(不稳定,先别用,可能劣化模型效果!)"))
with gr.Row(visible=False):
@@ -1411,38 +1394,40 @@ 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.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)
- with gr.Row():
- asr_model = gr.Dropdown(
- label=i18n("ASR 模型"),
- choices=list(asr_dict.keys()),
- interactive=True,
- value="达摩 ASR (中文)",
- )
- asr_size = gr.Dropdown(
- label=i18n("ASR 模型尺寸"), choices=["large"], interactive=True, value="large"
- )
- asr_lang = gr.Dropdown(
- label=i18n("ASR 语言设置"), choices=["zh", "yue"], interactive=True, value="zh"
- )
- asr_precision = gr.Dropdown(
- label=i18n("数据类型精度"), choices=["float32"], interactive=True, value="float32"
- )
- with gr.Row():
- asr_info = gr.Textbox(label=process_info(process_name_asr, "info"))
- open_asr_button = gr.Button(
- value=process_info(process_name_asr, "open"), variant="primary", visible=True
- )
- close_asr_button = gr.Button(
- value=process_info(process_name_asr, "close"), variant="primary", visible=False
- )
+ 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
+ )
+ with gr.Row():
+ asr_model = gr.Dropdown(
+ label=i18n("ASR 模型"),
+ choices=list(asr_dict.keys()),
+ interactive=True,
+ value="达摩 ASR (中文)",
+ )
+ asr_size = gr.Dropdown(
+ label=i18n("ASR 模型尺寸"), choices=["large"], interactive=True, value="large"
+ )
+ asr_lang = gr.Dropdown(
+ label=i18n("ASR 语言设置"), choices=["zh", "yue"], interactive=True, value="zh"
+ )
+ asr_precision = gr.Dropdown(
+ label=i18n("数据类型精度"), choices=["float32"], interactive=True, value="float32"
+ )
+ with gr.Row():
+ asr_info = gr.Textbox(label=process_info(process_name_asr, "info"))
+ open_asr_button = gr.Button(
+ value=process_info(process_name_asr, "open"), variant="primary", visible=True
+ )
+ close_asr_button = gr.Button(
+ value=process_info(process_name_asr, "close"), variant="primary", visible=False
+ )
def change_lang_choices(key): # 根据选择的模型修改可选的语言
return {"__type__": "update", "choices": asr_dict[key]["lang"], "value": asr_dict[key]["lang"][0]}
@@ -1466,165 +1451,186 @@ 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.Row():
- with gr.Column(scale=3):
- with gr.Row():
- path_list = gr.Textbox(
- label=i18n("标注文件路径 (含文件后缀 *.list)"),
- value="D:\\RVC1006\\GPT-SoVITS\\raw\\xxx.list",
- 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)
- close_label = gr.Button(
- value=process_info(process_name_subfix, "close"), variant="primary", visible=False
- )
-
- open_label.click(change_label, [path_list], [label_info, open_label, close_label])
- close_label.click(change_label, [path_list], [label_info, open_label, close_label])
- open_uvr5.click(change_uvr5, [], [uvr5_info, open_uvr5, close_uvr5])
- close_uvr5.click(change_uvr5, [], [uvr5_info, open_uvr5, close_uvr5])
-
- with gr.TabItem(i18n("1-GPT-SoVITS-TTS")):
- with gr.Row():
+ with gr.Accordion(label="0d-" + i18n("语音文本校对标注工具")):
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,)
- pretrained_s2G = gr.Textbox(
- label=i18n("预训练SoVITS-G模型路径"),
- value=pretrained_sovits_name[version],
- interactive=True,
- lines=2,
- max_lines=3,
- 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,
+ with gr.Column(scale=3):
+ with gr.Row():
+ path_list = gr.Textbox(
+ label=i18n("标注文件路径 (含文件后缀 *.list)"),
+ value="D:\\RVC1006\\GPT-SoVITS\\raw\\xxx.list",
+ 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
)
- pretrained_s1 = gr.Textbox(
- label=i18n("预训练GPT模型路径"),
- value=pretrained_gpt_name[version],
- interactive=True,
- lines=2,
- max_lines=3,
- scale=5,
+ close_label = gr.Button(
+ value=process_info(process_name_subfix, "close"), variant="primary", visible=False
)
- with gr.TabItem("1A-" + i18n("训练集格式化工具")):
- gr.Markdown(value=i18n("输出logs/实验名目录下应有23456开头的文件和文件夹"))
- with gr.Row():
- with gr.Row():
- inp_text = gr.Textbox(
- label=i18n("*文本标注文件"),
- value=r"D:\RVC1006\GPT-SoVITS\raw\xxx.list",
- interactive=True,
- scale=10,
- )
- with gr.Row():
- inp_wav_dir = gr.Textbox(
- label=i18n("*训练集音频文件目录"),
- # value=r"D:\RVC1006\GPT-SoVITS\raw\xxx",
- interactive=True,
- placeholder=i18n(
- "填切割后音频所在目录!读取的音频文件完整路径=该目录-拼接-list文件里波形对应的文件名(不是全路径)。如果留空则使用.list文件里的绝对全路径。"
- ),
- scale=10,
- )
+ open_label.click(change_label, [path_list], [label_info, open_label, close_label])
+ close_label.click(change_label, [path_list], [label_info, open_label, close_label])
+ open_uvr5.click(change_uvr5, [], [uvr5_info, open_uvr5, close_uvr5])
+ close_uvr5.click(change_uvr5, [], [uvr5_info, open_uvr5, close_uvr5])
- gr.Markdown(value="1Aa-" + process_name_1a)
+ with gr.TabItem(i18n("1-GPT-SoVITS-TTS")):
+ with gr.Accordion(i18n("微调模型信息")):
with gr.Row():
- with gr.Row():
- gpu_numbers1a = gr.Textbox(
- label=i18n("GPU卡号以-分割,每个卡号一个进程"),
- value="%s-%s" % (gpus, gpus),
+ with gr.Row(equal_height=True):
+ exp_name = gr.Textbox(
+ label=i18n("*实验/模型名"),
+ value="xxx",
interactive=True,
+ scale=3,
)
- with gr.Row():
- bert_pretrained_dir = gr.Textbox(
- label=i18n("预训练中文BERT模型路径"),
- value="GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large",
+ gpu_info_box = gr.Textbox(
+ label=i18n("显卡信息"),
+ value=gpu_info,
+ visible=True,
interactive=False,
- lines=2,
- )
- with gr.Row():
- button1a_open = gr.Button(
- value=process_info(process_name_1a, "open"), variant="primary", visible=True
+ scale=5,
)
- button1a_close = gr.Button(
- value=process_info(process_name_1a, "close"), variant="primary", visible=False
+ version_checkbox = gr.Radio(
+ label=i18n("训练模型的版本"),
+ value=version,
+ choices=["v1", "v2", "v4", "v2Pro", "v2ProPlus"],
+ scale=5,
)
- with gr.Row():
- info1a = gr.Textbox(label=process_info(process_name_1a, "info"))
-
- gr.Markdown(value="1Ab-" + process_name_1b)
+ with gr.Accordion(label=i18n("预训练模型路径"), open=False):
with gr.Row():
- with gr.Row():
- gpu_numbers1Ba = gr.Textbox(
- label=i18n("GPU卡号以-分割,每个卡号一个进程"),
- value="%s-%s" % (gpus, gpus),
+ 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,
)
- with gr.Row():
- cnhubert_base_dir = gr.Textbox(
- label=i18n("预训练SSL模型路径"),
- value="GPT_SoVITS/pretrained_models/chinese-hubert-base",
- interactive=False,
- lines=2,
- )
- with gr.Row():
- button1b_open = gr.Button(
- value=process_info(process_name_1b, "open"), variant="primary", visible=True
- )
- button1b_close = gr.Button(
- value=process_info(process_name_1b, "close"), variant="primary", visible=False
+ pretrained_s2G = gr.Textbox(
+ label=i18n("预训练SoVITS-G模型路径"),
+ value=pretrained_sovits_name[version],
+ interactive=True,
+ lines=1,
+ max_lines=1,
+ scale=5,
)
- with gr.Row():
- info1b = gr.Textbox(label=process_info(process_name_1b, "info"))
-
- gr.Markdown(value="1Ac-" + process_name_1c)
- with gr.Row():
- with gr.Row():
- gpu_numbers1c = gr.Textbox(
- label=i18n("GPU卡号以-分割,每个卡号一个进程"),
- value="%s-%s" % (gpus, gpus),
+ pretrained_s2D = gr.Textbox(
+ label=i18n("预训练SoVITS-D模型路径"),
+ value=pretrained_sovits_name[version].replace("s2G", "s2D"),
interactive=True,
+ lines=1,
+ max_lines=1,
+ scale=5,
)
+
+ with gr.TabItem("1A-" + i18n("训练集格式化工具")):
+ with gr.Accordion(label=i18n("输出logs/实验名目录下应有23456开头的文件和文件夹")):
with gr.Row():
- pretrained_s2G_ = gr.Textbox(
- label=i18n("预训练SoVITS-G模型路径"),
- value=pretrained_sovits_name[version],
- interactive=False,
- lines=2,
- )
+ with gr.Row():
+ inp_text = gr.Textbox(
+ label=i18n("*文本标注文件"),
+ value=r"D:\RVC1006\GPT-SoVITS\raw\xxx.list",
+ interactive=True,
+ scale=10,
+ )
+ with gr.Row():
+ inp_wav_dir = gr.Textbox(
+ label=i18n("*训练集音频文件目录"),
+ # value=r"D:\RVC1006\GPT-SoVITS\raw\xxx",
+ interactive=True,
+ placeholder=i18n(
+ "填切割后音频所在目录!读取的音频文件完整路径=该目录-拼接-list文件里波形对应的文件名(不是全路径)。如果留空则使用.list文件里的绝对全路径。"
+ ),
+ scale=10,
+ )
+
+ with gr.Accordion(label="1Aa-" + process_name_1a):
with gr.Row():
- button1c_open = gr.Button(
- value=process_info(process_name_1c, "open"), variant="primary", visible=True
- )
- button1c_close = gr.Button(
- value=process_info(process_name_1c, "close"), variant="primary", visible=False
- )
+ with gr.Row():
+ gpu_numbers1a = gr.Textbox(
+ label=i18n("GPU卡号以-分割,每个卡号一个进程"),
+ value="%s-%s" % (gpus, gpus),
+ interactive=True,
+ )
+ with gr.Row():
+ bert_pretrained_dir = gr.Textbox(
+ label=i18n("预训练中文BERT模型路径"),
+ value="GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large",
+ interactive=False,
+ lines=2,
+ )
+ with gr.Row():
+ button1a_open = gr.Button(
+ value=process_info(process_name_1a, "open"), variant="primary", visible=True
+ )
+ button1a_close = gr.Button(
+ value=process_info(process_name_1a, "close"), variant="primary", visible=False
+ )
+ with gr.Row():
+ info1a = gr.Textbox(label=process_info(process_name_1a, "info"))
+
+ with gr.Accordion(label="1Ab-" + process_name_1b):
with gr.Row():
- info1c = gr.Textbox(label=process_info(process_name_1c, "info"))
+ with gr.Row():
+ gpu_numbers1Ba = gr.Textbox(
+ label=i18n("GPU卡号以-分割,每个卡号一个进程"),
+ value="%s-%s" % (gpus, gpus),
+ interactive=True,
+ )
+ with gr.Row():
+ cnhubert_base_dir = gr.Textbox(
+ label=i18n("预训练SSL模型路径"),
+ value="GPT_SoVITS/pretrained_models/chinese-hubert-base",
+ interactive=False,
+ lines=2,
+ )
+ with gr.Row():
+ button1b_open = gr.Button(
+ value=process_info(process_name_1b, "open"), variant="primary", visible=True
+ )
+ button1b_close = gr.Button(
+ value=process_info(process_name_1b, "close"), variant="primary", visible=False
+ )
+ with gr.Row():
+ info1b = gr.Textbox(label=process_info(process_name_1b, "info"))
- gr.Markdown(value="1Aabc-" + process_name_1abc)
- with gr.Row():
+ with gr.Accordion(label="1Ac-" + process_name_1c):
with gr.Row():
- button1abc_open = gr.Button(
- value=process_info(process_name_1abc, "open"), variant="primary", visible=True
- )
- button1abc_close = gr.Button(
- value=process_info(process_name_1abc, "close"), variant="primary", visible=False
- )
+ with gr.Row():
+ gpu_numbers1c = gr.Textbox(
+ label=i18n("GPU卡号以-分割,每个卡号一个进程"),
+ value="%s-%s" % (gpus, gpus),
+ interactive=True,
+ )
+ with gr.Row():
+ pretrained_s2G_ = gr.Textbox(
+ label=i18n("预训练SoVITS-G模型路径"),
+ value=pretrained_sovits_name[version],
+ interactive=False,
+ lines=2,
+ )
+ with gr.Row():
+ button1c_open = gr.Button(
+ value=process_info(process_name_1c, "open"), variant="primary", visible=True
+ )
+ button1c_close = gr.Button(
+ value=process_info(process_name_1c, "close"), variant="primary", visible=False
+ )
+ with gr.Row():
+ info1c = gr.Textbox(label=process_info(process_name_1c, "info"))
+
+ with gr.Accordion(label="1Aabc-" + process_name_1abc):
with gr.Row():
- info1abc = gr.Textbox(label=process_info(process_name_1abc, "info"))
+ with gr.Row():
+ button1abc_open = gr.Button(
+ value=process_info(process_name_1abc, "open"), variant="primary", visible=True
+ )
+ button1abc_close = gr.Button(
+ value=process_info(process_name_1abc, "close"), variant="primary", visible=False
+ )
+ with gr.Row():
+ info1abc = gr.Textbox(label=process_info(process_name_1abc, "info"))
pretrained_s2G.change(sync, [pretrained_s2G], [pretrained_s2G_])
open_asr_button.click(
@@ -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,147 +1700,151 @@ 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.Row():
- with gr.Column():
- with gr.Row():
- batch_size = gr.Slider(
- minimum=1,
- maximum=default_max_batch_size,
- step=1,
- label=i18n("每张显卡的batch_size"),
- value=default_batch_size,
- interactive=True,
- )
- total_epoch = gr.Slider(
- minimum=1,
- maximum=max_sovits_epoch,
- step=1,
- label=i18n("总训练轮数total_epoch,不建议太高"),
- value=default_sovits_epoch,
- interactive=True,
- )
- with gr.Row():
- text_low_lr_rate = gr.Slider(
- minimum=0.2,
- maximum=0.6,
- step=0.05,
- label=i18n("文本模块学习率权重"),
- value=0.4,
- visible=True if version not in v3v4set else False,
- ) # v3v4 not need
- lora_rank = gr.Radio(
- label=i18n("LoRA秩"),
- value="32",
- choices=["16", "32", "64", "128"],
- visible=True if version in v3v4set else False,
- ) # v1v2 not need
- save_every_epoch = gr.Slider(
- minimum=1,
- maximum=max_sovits_save_every_epoch,
- step=1,
- label=i18n("保存频率save_every_epoch"),
- value=default_sovits_save_every_epoch,
- interactive=True,
- )
- with gr.Column():
- with gr.Column():
- if_save_latest = gr.Checkbox(
- label=i18n("是否仅保存最新的权重文件以节省硬盘空间"),
- value=True,
- interactive=True,
- show_label=True,
- )
- if_save_every_weights = gr.Checkbox(
- label=i18n("是否在每次保存时间点将最终小模型保存至weights文件夹"),
- value=True,
- interactive=True,
- show_label=True,
- )
- if_grad_ckpt = gr.Checkbox(
- label="v3是否开启梯度检查点节省显存占用",
- value=False,
- interactive=True if version in v3v4set else False,
- show_label=True,
- visible=False,
- ) # 只有V3s2可以用
- with gr.Row():
- gpu_numbers1Ba = gr.Textbox(
- label=i18n("GPU卡号以-分割,每个卡号一个进程"), value="%s" % (gpus), interactive=True
- )
- with gr.Row():
+ with gr.Accordion(label="1Ba-" + i18n("SoVITS 训练: 模型权重文件在 SoVITS_weights/")):
with gr.Row():
- button1Ba_open = gr.Button(
- value=process_info(process_name_sovits, "open"), variant="primary", visible=True
- )
- button1Ba_close = gr.Button(
- value=process_info(process_name_sovits, "close"), variant="primary", visible=False
- )
+ with gr.Column():
+ with gr.Row():
+ batch_size = gr.Slider(
+ minimum=1,
+ maximum=default_max_batch_size,
+ step=1,
+ label=i18n("每张显卡的batch_size"),
+ value=default_batch_size,
+ interactive=True,
+ )
+ total_epoch = gr.Slider(
+ minimum=1,
+ maximum=max_sovits_epoch,
+ step=1,
+ label=i18n("总训练轮数total_epoch,不建议太高"),
+ value=default_sovits_epoch,
+ interactive=True,
+ )
+ with gr.Row():
+ text_low_lr_rate = gr.Slider(
+ minimum=0.2,
+ maximum=0.6,
+ step=0.05,
+ label=i18n("文本模块学习率权重"),
+ value=0.4,
+ visible=True if version not in v3v4set else False,
+ ) # v3v4 not need
+ lora_rank = gr.Radio(
+ label=i18n("LoRA秩"),
+ value="32",
+ choices=["16", "32", "64", "128"],
+ visible=True if version in v3v4set else False,
+ ) # v1v2 not need
+ save_every_epoch = gr.Slider(
+ minimum=1,
+ maximum=max_sovits_save_every_epoch,
+ step=1,
+ label=i18n("保存频率save_every_epoch"),
+ value=default_sovits_save_every_epoch,
+ interactive=True,
+ )
+ with gr.Column():
+ with gr.Column():
+ if_save_latest = gr.Checkbox(
+ label=i18n("是否仅保存最新的权重文件以节省硬盘空间"),
+ value=True,
+ interactive=True,
+ show_label=True,
+ )
+ if_save_every_weights = gr.Checkbox(
+ label=i18n("是否在每次保存时间点将最终小模型保存至weights文件夹"),
+ value=True,
+ interactive=True,
+ show_label=True,
+ )
+ if_grad_ckpt = gr.Checkbox(
+ label="v3是否开启梯度检查点节省显存占用",
+ value=False,
+ interactive=True if version in v3v4set else False,
+ show_label=True,
+ visible=False,
+ ) # 只有V3s2可以用
+ with gr.Row():
+ gpu_numbers1Ba = gr.Textbox(
+ label=i18n("GPU卡号以-分割,每个卡号一个进程"),
+ value="%s" % (gpus),
+ interactive=True,
+ )
with gr.Row():
- info1Ba = gr.Textbox(label=process_info(process_name_sovits, "info"))
- gr.Markdown(value="1Bb-" + i18n("GPT 训练: 模型权重文件在 GPT_weights/"))
- with gr.Row():
- with gr.Column():
with gr.Row():
- batch_size1Bb = gr.Slider(
- minimum=1,
- maximum=40,
- step=1,
- label=i18n("每张显卡的batch_size"),
- value=default_batch_size_s1,
- interactive=True,
+ button1Ba_open = gr.Button(
+ value=process_info(process_name_sovits, "open"), variant="primary", visible=True
)
- total_epoch1Bb = gr.Slider(
- minimum=2,
- maximum=50,
- step=1,
- label=i18n("总训练轮数total_epoch"),
- value=15,
- interactive=True,
+ button1Ba_close = gr.Button(
+ value=process_info(process_name_sovits, "close"), variant="primary", visible=False
)
with gr.Row():
- save_every_epoch1Bb = gr.Slider(
- minimum=1,
- maximum=50,
- step=1,
- label=i18n("保存频率save_every_epoch"),
- value=5,
- interactive=True,
- )
- if_dpo = gr.Checkbox(
- label=i18n("是否开启DPO训练选项(实验性)"),
- value=False,
- interactive=True,
- show_label=True,
- )
- with gr.Column():
+ info1Ba = gr.Textbox(label=process_info(process_name_sovits, "info"))
+ with gr.Accordion(label="1Bb-" + i18n("GPT 训练: 模型权重文件在 GPT_weights/")):
+ with gr.Row():
with gr.Column():
- if_save_latest1Bb = gr.Checkbox(
- label=i18n("是否仅保存最新的权重文件以节省硬盘空间"),
- value=True,
- interactive=True,
- show_label=True,
+ with gr.Row():
+ batch_size1Bb = gr.Slider(
+ minimum=1,
+ maximum=40,
+ step=1,
+ label=i18n("每张显卡的batch_size"),
+ value=default_batch_size_s1,
+ interactive=True,
+ )
+ total_epoch1Bb = gr.Slider(
+ minimum=2,
+ maximum=50,
+ step=1,
+ label=i18n("总训练轮数total_epoch"),
+ value=15,
+ interactive=True,
+ )
+ with gr.Row():
+ save_every_epoch1Bb = gr.Slider(
+ minimum=1,
+ maximum=50,
+ step=1,
+ label=i18n("保存频率save_every_epoch"),
+ value=5,
+ interactive=True,
+ )
+ if_dpo = gr.Checkbox(
+ label=i18n("是否开启DPO训练选项(实验性)"),
+ value=False,
+ interactive=True,
+ show_label=True,
+ )
+ with gr.Column():
+ with gr.Column():
+ if_save_latest1Bb = gr.Checkbox(
+ label=i18n("是否仅保存最新的权重文件以节省硬盘空间"),
+ value=True,
+ interactive=True,
+ show_label=True,
+ )
+ if_save_every_weights1Bb = gr.Checkbox(
+ label=i18n("是否在每次保存时间点将最终小模型保存至weights文件夹"),
+ value=True,
+ interactive=True,
+ show_label=True,
+ )
+ with gr.Row():
+ gpu_numbers1Bb = gr.Textbox(
+ label=i18n("GPU卡号以-分割,每个卡号一个进程"),
+ value="%s" % (gpus),
+ interactive=True,
+ )
+ with gr.Row():
+ with gr.Row():
+ button1Bb_open = gr.Button(
+ value=process_info(process_name_gpt, "open"), variant="primary", visible=True
)
- if_save_every_weights1Bb = gr.Checkbox(
- label=i18n("是否在每次保存时间点将最终小模型保存至weights文件夹"),
- value=True,
- interactive=True,
- show_label=True,
+ button1Bb_close = gr.Button(
+ value=process_info(process_name_gpt, "close"), variant="primary", visible=False
)
with gr.Row():
- gpu_numbers1Bb = gr.Textbox(
- label=i18n("GPU卡号以-分割,每个卡号一个进程"), value="%s" % (gpus), interactive=True
- )
- with gr.Row():
- with gr.Row():
- button1Bb_open = gr.Button(
- value=process_info(process_name_gpt, "open"), variant="primary", visible=True
- )
- button1Bb_close = gr.Button(
- value=process_info(process_name_gpt, "close"), variant="primary", visible=False
- )
- with gr.Row():
- info1Bb = gr.Textbox(label=process_info(process_name_gpt, "info"))
+ info1Bb = gr.Textbox(label=process_info(process_name_gpt, "info"))
button1Ba_close.click(close1Ba, [], [info1Ba, button1Ba_open, button1Ba_close])
button1Bb_close.click(close1Bb, [], [info1Bb, button1Bb_open, button1Bb_close])
@@ -1844,37 +1856,40 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False) as app:
)
)
with gr.Row():
- with gr.Row():
- GPT_dropdown = gr.Dropdown(
- label=i18n("GPT模型列表"),
- choices=GPT_names,
- value=GPT_names[-1],
- interactive=True,
- )
- SoVITS_dropdown = gr.Dropdown(
- label=i18n("SoVITS模型列表"),
- choices=SoVITS_names,
- value=SoVITS_names[0],
- interactive=True,
- )
- with gr.Row():
- gpu_number_1C = gr.Textbox(label=i18n("GPU卡号,只能填1个整数"), value=gpus, interactive=True)
- refresh_button = gr.Button(i18n("刷新模型路径"), variant="primary")
+ with gr.Column(scale=2):
+ with gr.Row():
+ GPT_dropdown = gr.Dropdown(
+ label=i18n("GPT模型列表"),
+ choices=GPT_names,
+ value=GPT_names[-1],
+ interactive=True,
+ )
+ SoVITS_dropdown = gr.Dropdown(
+ label=i18n("SoVITS模型列表"),
+ choices=SoVITS_names,
+ 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
+ )
+ 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,
[