Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,934 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import sys
|
3 |
# to avoid the modified user.pth file
|
|
|
1 |
+
import os,shutil,sys,pdb,re
|
2 |
+
version="v2"#if sys.argv[-1]=="v2" else"v1"
|
3 |
+
os.environ["version"]=version
|
4 |
+
now_dir = os.getcwd()
|
5 |
+
sys.path.insert(0, now_dir)
|
6 |
+
import json,yaml,warnings,torch
|
7 |
+
import platform
|
8 |
+
import psutil
|
9 |
+
import signal
|
10 |
+
|
11 |
+
warnings.filterwarnings("ignore")
|
12 |
+
torch.manual_seed(233333)
|
13 |
+
tmp = os.path.join(now_dir, "TEMP")
|
14 |
+
os.makedirs(tmp, exist_ok=True)
|
15 |
+
os.environ["TEMP"] = tmp
|
16 |
+
if(os.path.exists(tmp)):
|
17 |
+
for name in os.listdir(tmp):
|
18 |
+
if(name=="jieba.cache"):continue
|
19 |
+
path="%s/%s"%(tmp,name)
|
20 |
+
delete=os.remove if os.path.isfile(path) else shutil.rmtree
|
21 |
+
try:
|
22 |
+
delete(path)
|
23 |
+
except Exception as e:
|
24 |
+
print(str(e))
|
25 |
+
pass
|
26 |
+
import site
|
27 |
+
site_packages_roots = []
|
28 |
+
for path in site.getsitepackages():
|
29 |
+
if "packages" in path:
|
30 |
+
site_packages_roots.append(path)
|
31 |
+
if(site_packages_roots==[]):site_packages_roots=["%s/runtime/Lib/site-packages" % now_dir]
|
32 |
+
#os.environ["OPENBLAS_NUM_THREADS"] = "4"
|
33 |
+
os.environ["no_proxy"] = "localhost, 127.0.0.1, ::1"
|
34 |
+
os.environ["all_proxy"] = ""
|
35 |
+
for site_packages_root in site_packages_roots:
|
36 |
+
if os.path.exists(site_packages_root):
|
37 |
+
try:
|
38 |
+
with open("%s/users.pth" % (site_packages_root), "w") as f:
|
39 |
+
f.write(
|
40 |
+
"%s\n%s/tools\n%s/tools/damo_asr\n%s/GPT_SoVITS\n%s/tools/uvr5"
|
41 |
+
% (now_dir, now_dir, now_dir, now_dir, now_dir)
|
42 |
+
)
|
43 |
+
break
|
44 |
+
except PermissionError:
|
45 |
+
pass
|
46 |
+
from tools import my_utils
|
47 |
+
import traceback
|
48 |
+
import shutil
|
49 |
+
import pdb
|
50 |
+
import gradio as gr
|
51 |
+
from subprocess import Popen
|
52 |
+
import signal
|
53 |
+
from config import python_exec,infer_device,is_half,exp_root,webui_port_main,webui_port_infer_tts,webui_port_uvr5,webui_port_subfix,is_share
|
54 |
+
from tools.i18n.i18n import I18nAuto
|
55 |
+
i18n = I18nAuto()
|
56 |
+
from scipy.io import wavfile
|
57 |
+
from tools.my_utils import load_audio
|
58 |
+
from multiprocessing import cpu_count
|
59 |
+
|
60 |
+
# os.environ['PYTORCH_ENABLE_MPS_FALLBACK'] = '1' # 当遇到mps不支持的步骤时使用cpu
|
61 |
+
|
62 |
+
n_cpu=cpu_count()
|
63 |
+
|
64 |
+
ngpu = torch.cuda.device_count()
|
65 |
+
gpu_infos = []
|
66 |
+
mem = []
|
67 |
+
if_gpu_ok = False
|
68 |
+
|
69 |
+
# 判断是否有能用来训练和加速推理的N卡
|
70 |
+
ok_gpu_keywords={"10","16","20","30","40","A2","A3","A4","P4","A50","500","A60","70","80","90","M4","T4","TITAN","L4","4060","H"}
|
71 |
+
set_gpu_numbers=set()
|
72 |
+
if torch.cuda.is_available() or ngpu != 0:
|
73 |
+
for i in range(ngpu):
|
74 |
+
gpu_name = torch.cuda.get_device_name(i)
|
75 |
+
if any(value in gpu_name.upper()for value in ok_gpu_keywords):
|
76 |
+
# A10#A100#V100#A40#P40#M40#K80#A4500
|
77 |
+
if_gpu_ok = True # 至少有一张能用的N卡
|
78 |
+
gpu_infos.append("%s\t%s" % (i, gpu_name))
|
79 |
+
set_gpu_numbers.add(i)
|
80 |
+
mem.append(int(torch.cuda.get_device_properties(i).total_memory/ 1024/ 1024/ 1024+ 0.4))
|
81 |
+
# # 判断是否支持mps加速
|
82 |
+
# if torch.backends.mps.is_available():
|
83 |
+
# if_gpu_ok = True
|
84 |
+
# gpu_infos.append("%s\t%s" % ("0", "Apple GPU"))
|
85 |
+
# mem.append(psutil.virtual_memory().total/ 1024 / 1024 / 1024) # 实测使用系统内存作为显存不会爆显存
|
86 |
+
|
87 |
+
if if_gpu_ok and len(gpu_infos) > 0:
|
88 |
+
gpu_info = "\n".join(gpu_infos)
|
89 |
+
default_batch_size = min(mem) // 2
|
90 |
+
else:
|
91 |
+
gpu_info = ("%s\t%s" % ("0", "CPU"))
|
92 |
+
gpu_infos.append("%s\t%s" % ("0", "CPU"))
|
93 |
+
set_gpu_numbers.add(0)
|
94 |
+
default_batch_size = int(psutil.virtual_memory().total/ 1024 / 1024 / 1024 / 2)
|
95 |
+
gpus = "-".join([i[0] for i in gpu_infos])
|
96 |
+
default_gpu_numbers=str(sorted(list(set_gpu_numbers))[0])
|
97 |
+
def fix_gpu_number(input):#将越界的number强制改到界内
|
98 |
+
try:
|
99 |
+
if(int(input)not in set_gpu_numbers):return default_gpu_numbers
|
100 |
+
except:return input
|
101 |
+
return input
|
102 |
+
def fix_gpu_numbers(inputs):
|
103 |
+
output=[]
|
104 |
+
try:
|
105 |
+
for input in inputs.split(","):output.append(str(fix_gpu_number(input)))
|
106 |
+
return ",".join(output)
|
107 |
+
except:
|
108 |
+
return inputs
|
109 |
+
pretrained_sovits_name="GPT_SoVITS/pretrained_models/s2G2333k.pth"
|
110 |
+
pretrained_gpt_name="GPT_SoVITS/pretrained_models/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt"
|
111 |
+
def get_weights_names():
|
112 |
+
SoVITS_names = [pretrained_sovits_name]
|
113 |
+
for name in os.listdir(SoVITS_weight_root):
|
114 |
+
if name.endswith(".pth"):SoVITS_names.append(name)
|
115 |
+
GPT_names = [pretrained_gpt_name]
|
116 |
+
for name in os.listdir(GPT_weight_root):
|
117 |
+
if name.endswith(".ckpt"): GPT_names.append(name)
|
118 |
+
return SoVITS_names,GPT_names
|
119 |
+
SoVITS_weight_root="SoVITS_weights"
|
120 |
+
GPT_weight_root="GPT_weights"
|
121 |
+
os.makedirs(SoVITS_weight_root,exist_ok=True)
|
122 |
+
os.makedirs(GPT_weight_root,exist_ok=True)
|
123 |
+
SoVITS_names,GPT_names = get_weights_names()
|
124 |
+
|
125 |
+
def custom_sort_key(s):
|
126 |
+
# 使用正则表达式提取字符串中的数字部分和非数字部分
|
127 |
+
parts = re.split('(\d+)', s)
|
128 |
+
# 将数字部分转换为整数,非数字部分保持不变
|
129 |
+
parts = [int(part) if part.isdigit() else part for part in parts]
|
130 |
+
return parts
|
131 |
+
|
132 |
+
def change_choices():
|
133 |
+
SoVITS_names, GPT_names = get_weights_names()
|
134 |
+
return {"choices": sorted(SoVITS_names,key=custom_sort_key), "__type__": "update"}, {"choices": sorted(GPT_names,key=custom_sort_key), "__type__": "update"}
|
135 |
+
|
136 |
+
p_label=None
|
137 |
+
p_uvr5=None
|
138 |
+
p_asr=None
|
139 |
+
p_denoise=None
|
140 |
+
p_tts_inference=None
|
141 |
+
|
142 |
+
def kill_proc_tree(pid, including_parent=True):
|
143 |
+
try:
|
144 |
+
parent = psutil.Process(pid)
|
145 |
+
except psutil.NoSuchProcess:
|
146 |
+
# Process already terminated
|
147 |
+
return
|
148 |
+
|
149 |
+
children = parent.children(recursive=True)
|
150 |
+
for child in children:
|
151 |
+
try:
|
152 |
+
os.kill(child.pid, signal.SIGTERM) # or signal.SIGKILL
|
153 |
+
except OSError:
|
154 |
+
pass
|
155 |
+
if including_parent:
|
156 |
+
try:
|
157 |
+
os.kill(parent.pid, signal.SIGTERM) # or signal.SIGKILL
|
158 |
+
except OSError:
|
159 |
+
pass
|
160 |
+
|
161 |
+
system=platform.system()
|
162 |
+
def kill_process(pid):
|
163 |
+
if(system=="Windows"):
|
164 |
+
cmd = "taskkill /t /f /pid %s" % pid
|
165 |
+
os.system(cmd)
|
166 |
+
else:
|
167 |
+
kill_proc_tree(pid)
|
168 |
+
|
169 |
+
|
170 |
+
def change_label(if_label,path_list):
|
171 |
+
global p_label
|
172 |
+
if(if_label==True and p_label==None):
|
173 |
+
path_list=my_utils.clean_path(path_list)
|
174 |
+
cmd = '"%s" tools/subfix_webui.py --load_list "%s" --webui_port %s --is_share %s'%(python_exec,path_list,webui_port_subfix,is_share)
|
175 |
+
yield i18n("打标工具WebUI已开启")
|
176 |
+
print(cmd)
|
177 |
+
p_label = Popen(cmd, shell=True)
|
178 |
+
elif(if_label==False and p_label!=None):
|
179 |
+
kill_process(p_label.pid)
|
180 |
+
p_label=None
|
181 |
+
yield i18n("打标工具WebUI已关闭")
|
182 |
+
|
183 |
+
def change_uvr5(if_uvr5):
|
184 |
+
global p_uvr5
|
185 |
+
if(if_uvr5==True and p_uvr5==None):
|
186 |
+
cmd = '"%s" tools/uvr5/webui.py "%s" %s %s %s'%(python_exec,infer_device,is_half,webui_port_uvr5,is_share)
|
187 |
+
yield i18n("UVR5已开启")
|
188 |
+
print(cmd)
|
189 |
+
p_uvr5 = Popen(cmd, shell=True)
|
190 |
+
elif(if_uvr5==False and p_uvr5!=None):
|
191 |
+
kill_process(p_uvr5.pid)
|
192 |
+
p_uvr5=None
|
193 |
+
yield i18n("UVR5已关闭")
|
194 |
+
|
195 |
+
def change_tts_inference(if_tts,bert_path,cnhubert_base_path,gpu_number,gpt_path,sovits_path):
|
196 |
+
global p_tts_inference
|
197 |
+
if(if_tts==True and p_tts_inference==None):
|
198 |
+
os.environ["gpt_path"]=gpt_path if "/" in gpt_path else "%s/%s"%(GPT_weight_root,gpt_path)
|
199 |
+
os.environ["sovits_path"]=sovits_path if "/"in sovits_path else "%s/%s"%(SoVITS_weight_root,sovits_path)
|
200 |
+
os.environ["cnhubert_base_path"]=cnhubert_base_path
|
201 |
+
os.environ["bert_path"]=bert_path
|
202 |
+
os.environ["_CUDA_VISIBLE_DEVICES"]=fix_gpu_number(gpu_number)
|
203 |
+
os.environ["is_half"]=str(is_half)
|
204 |
+
os.environ["infer_ttswebui"]=str(webui_port_infer_tts)
|
205 |
+
os.environ["is_share"]=str(is_share)
|
206 |
+
cmd = '"%s" GPT_SoVITS/inference_webui.py'%(python_exec)
|
207 |
+
yield i18n("TTS推理进程已开启")
|
208 |
+
print(cmd)
|
209 |
+
p_tts_inference = Popen(cmd, shell=True)
|
210 |
+
elif(if_tts==False and p_tts_inference!=None):
|
211 |
+
kill_process(p_tts_inference.pid)
|
212 |
+
p_tts_inference=None
|
213 |
+
yield i18n("TTS推理进程已关闭")
|
214 |
+
|
215 |
+
from tools.asr.config import asr_dict
|
216 |
+
def open_asr(asr_inp_dir, asr_opt_dir, asr_model, asr_model_size, asr_lang, asr_precision):
|
217 |
+
global p_asr
|
218 |
+
if(p_asr==None):
|
219 |
+
asr_inp_dir=my_utils.clean_path(asr_inp_dir)
|
220 |
+
asr_opt_dir=my_utils.clean_path(asr_opt_dir)
|
221 |
+
cmd = f'"{python_exec}" tools/asr/{asr_dict[asr_model]["path"]}'
|
222 |
+
cmd += f' -i "{asr_inp_dir}"'
|
223 |
+
cmd += f' -o "{asr_opt_dir}"'
|
224 |
+
cmd += f' -s {asr_model_size}'
|
225 |
+
cmd += f' -l {asr_lang}'
|
226 |
+
cmd += f" -p {asr_precision}"
|
227 |
+
output_file_name = os.path.basename(asr_inp_dir)
|
228 |
+
output_folder = asr_opt_dir or "output/asr_opt"
|
229 |
+
output_file_path = os.path.abspath(f'{output_folder}/{output_file_name}.list')
|
230 |
+
yield "ASR任务开启:%s"%cmd, {"__type__":"update","visible":False}, {"__type__":"update","visible":True}, {"__type__":"update"}
|
231 |
+
print(cmd)
|
232 |
+
p_asr = Popen(cmd, shell=True)
|
233 |
+
p_asr.wait()
|
234 |
+
p_asr=None
|
235 |
+
yield f"ASR任务完成, 查看终端进行下一步", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}, {"__type__":"update","value":output_file_path}
|
236 |
+
else:
|
237 |
+
yield "已有正在进行的ASR任务,需先终止才能开启下一次任务", {"__type__":"update","visible":False}, {"__type__":"update","visible":True}, {"__type__":"update"}
|
238 |
+
# return None
|
239 |
+
|
240 |
+
def close_asr():
|
241 |
+
global p_asr
|
242 |
+
if(p_asr!=None):
|
243 |
+
kill_process(p_asr.pid)
|
244 |
+
p_asr=None
|
245 |
+
return "已终止ASR进程", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}
|
246 |
+
def open_denoise(denoise_inp_dir, denoise_opt_dir):
|
247 |
+
global p_denoise
|
248 |
+
if(p_denoise==None):
|
249 |
+
denoise_inp_dir=my_utils.clean_path(denoise_inp_dir)
|
250 |
+
denoise_opt_dir=my_utils.clean_path(denoise_opt_dir)
|
251 |
+
cmd = '"%s" tools/cmd-denoise.py -i "%s" -o "%s" -p %s'%(python_exec,denoise_inp_dir,denoise_opt_dir,"float16"if is_half==True else "float32")
|
252 |
+
|
253 |
+
yield "语音降噪任务开启:%s"%cmd, {"__type__":"update","visible":False}, {"__type__":"update","visible":True}, {"__type__":"update"}
|
254 |
+
print(cmd)
|
255 |
+
p_denoise = Popen(cmd, shell=True)
|
256 |
+
p_denoise.wait()
|
257 |
+
p_denoise=None
|
258 |
+
yield f"语音降噪任务完成, 查看终端进行下一步", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}, {"__type__":"update","value":denoise_opt_dir}
|
259 |
+
else:
|
260 |
+
yield "已有正在进行的语音降噪任务,需先终止才能开启下一次任务", {"__type__":"update","visible":False}, {"__type__":"update","visible":True}, {"__type__":"update"}
|
261 |
+
# return None
|
262 |
+
|
263 |
+
def close_denoise():
|
264 |
+
global p_denoise
|
265 |
+
if(p_denoise!=None):
|
266 |
+
kill_process(p_denoise.pid)
|
267 |
+
p_denoise=None
|
268 |
+
return "已终止语音降噪进程", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}
|
269 |
+
|
270 |
+
p_train_SoVITS=None
|
271 |
+
def open1Ba(batch_size,total_epoch,exp_name,text_low_lr_rate,if_save_latest,if_save_every_weights,save_every_epoch,gpu_numbers1Ba,pretrained_s2G,pretrained_s2D):
|
272 |
+
global p_train_SoVITS
|
273 |
+
if(p_train_SoVITS==None):
|
274 |
+
with open("GPT_SoVITS/configs/s2.json")as f:
|
275 |
+
data=f.read()
|
276 |
+
data=json.loads(data)
|
277 |
+
s2_dir="%s/%s"%(exp_root,exp_name)
|
278 |
+
os.makedirs("%s/logs_s2"%(s2_dir),exist_ok=True)
|
279 |
+
if(is_half==False):
|
280 |
+
data["train"]["fp16_run"]=False
|
281 |
+
batch_size=max(1,batch_size//2)
|
282 |
+
data["train"]["batch_size"]=batch_size
|
283 |
+
data["train"]["epochs"]=total_epoch
|
284 |
+
data["train"]["text_low_lr_rate"]=text_low_lr_rate
|
285 |
+
data["train"]["pretrained_s2G"]=pretrained_s2G
|
286 |
+
data["train"]["pretrained_s2D"]=pretrained_s2D
|
287 |
+
data["train"]["if_save_latest"]=if_save_latest
|
288 |
+
data["train"]["if_save_every_weights"]=if_save_every_weights
|
289 |
+
data["train"]["save_every_epoch"]=save_every_epoch
|
290 |
+
data["train"]["gpu_numbers"]=gpu_numbers1Ba
|
291 |
+
data["data"]["exp_dir"]=data["s2_ckpt_dir"]=s2_dir
|
292 |
+
data["save_weight_dir"]=SoVITS_weight_root
|
293 |
+
data["name"]=exp_name
|
294 |
+
tmp_config_path="%s/tmp_s2.json"%tmp
|
295 |
+
with open(tmp_config_path,"w")as f:f.write(json.dumps(data))
|
296 |
+
|
297 |
+
cmd = '"%s" GPT_SoVITS/s2_train.py --config "%s"'%(python_exec,tmp_config_path)
|
298 |
+
yield "SoVITS训练开始:%s"%cmd, {"__type__":"update","visible":False}, {"__type__":"update","visible":True}
|
299 |
+
print(cmd)
|
300 |
+
p_train_SoVITS = Popen(cmd, shell=True)
|
301 |
+
p_train_SoVITS.wait()
|
302 |
+
p_train_SoVITS=None
|
303 |
+
yield "SoVITS训练完成", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}
|
304 |
+
else:
|
305 |
+
yield "已有正在进行的SoVITS训练任务,需先终止才能开启下一次任务", {"__type__":"update","visible":False}, {"__type__":"update","visible":True}
|
306 |
+
|
307 |
+
def close1Ba():
|
308 |
+
global p_train_SoVITS
|
309 |
+
if(p_train_SoVITS!=None):
|
310 |
+
kill_process(p_train_SoVITS.pid)
|
311 |
+
p_train_SoVITS=None
|
312 |
+
return "已终止SoVITS训练", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}
|
313 |
+
|
314 |
+
p_train_GPT=None
|
315 |
+
def open1Bb(batch_size,total_epoch,exp_name,if_dpo,if_save_latest,if_save_every_weights,save_every_epoch,gpu_numbers,pretrained_s1):
|
316 |
+
global p_train_GPT
|
317 |
+
if(p_train_GPT==None):
|
318 |
+
with open("GPT_SoVITS/configs/s1longer.yaml"if version=="v1"else "GPT_SoVITS/configs/s1longer-v2.yaml")as f:
|
319 |
+
data=f.read()
|
320 |
+
data=yaml.load(data, Loader=yaml.FullLoader)
|
321 |
+
s1_dir="%s/%s"%(exp_root,exp_name)
|
322 |
+
os.makedirs("%s/logs_s1"%(s1_dir),exist_ok=True)
|
323 |
+
if(is_half==False):
|
324 |
+
data["train"]["precision"]="32"
|
325 |
+
batch_size = max(1, batch_size // 2)
|
326 |
+
data["train"]["batch_size"]=batch_size
|
327 |
+
data["train"]["epochs"]=total_epoch
|
328 |
+
data["pretrained_s1"]=pretrained_s1
|
329 |
+
data["train"]["save_every_n_epoch"]=save_every_epoch
|
330 |
+
data["train"]["if_save_every_weights"]=if_save_every_weights
|
331 |
+
data["train"]["if_save_latest"]=if_save_latest
|
332 |
+
data["train"]["if_dpo"]=if_dpo
|
333 |
+
data["train"]["half_weights_save_dir"]=GPT_weight_root
|
334 |
+
data["train"]["exp_name"]=exp_name
|
335 |
+
data["train_semantic_path"]="%s/6-name2semantic.tsv"%s1_dir
|
336 |
+
data["train_phoneme_path"]="%s/2-name2text.txt"%s1_dir
|
337 |
+
data["output_dir"]="%s/logs_s1"%s1_dir
|
338 |
+
|
339 |
+
os.environ["_CUDA_VISIBLE_DEVICES"]=fix_gpu_numbers(gpu_numbers.replace("-",","))
|
340 |
+
os.environ["hz"]="25hz"
|
341 |
+
tmp_config_path="%s/tmp_s1.yaml"%tmp
|
342 |
+
with open(tmp_config_path, "w") as f:f.write(yaml.dump(data, default_flow_style=False))
|
343 |
+
# cmd = '"%s" GPT_SoVITS/s1_train.py --config_file "%s" --train_semantic_path "%s/6-name2semantic.tsv" --train_phoneme_path "%s/2-name2text.txt" --output_dir "%s/logs_s1"'%(python_exec,tmp_config_path,s1_dir,s1_dir,s1_dir)
|
344 |
+
cmd = '"%s" GPT_SoVITS/s1_train.py --config_file "%s" '%(python_exec,tmp_config_path)
|
345 |
+
yield "GPT训练开始:%s"%cmd, {"__type__":"update","visible":False}, {"__type__":"update","visible":True}
|
346 |
+
print(cmd)
|
347 |
+
p_train_GPT = Popen(cmd, shell=True)
|
348 |
+
p_train_GPT.wait()
|
349 |
+
p_train_GPT=None
|
350 |
+
yield "GPT训练完成", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}
|
351 |
+
else:
|
352 |
+
yield "已有正在进行的GPT训练任务,需先终止才能开启下一次任务", {"__type__":"update","visible":False}, {"__type__":"update","visible":True}
|
353 |
+
|
354 |
+
def close1Bb():
|
355 |
+
global p_train_GPT
|
356 |
+
if(p_train_GPT!=None):
|
357 |
+
kill_process(p_train_GPT.pid)
|
358 |
+
p_train_GPT=None
|
359 |
+
return "已终止GPT训练", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}
|
360 |
+
|
361 |
+
ps_slice=[]
|
362 |
+
def open_slice(inp,opt_root,threshold,min_length,min_interval,hop_size,max_sil_kept,_max,alpha,n_parts):
|
363 |
+
global ps_slice
|
364 |
+
inp = my_utils.clean_path(inp)
|
365 |
+
opt_root = my_utils.clean_path(opt_root)
|
366 |
+
if(os.path.exists(inp)==False):
|
367 |
+
yield "输入路径不存在", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}, {"__type__": "update"}, {"__type__": "update"}
|
368 |
+
return
|
369 |
+
if os.path.isfile(inp):n_parts=1
|
370 |
+
elif os.path.isdir(inp):pass
|
371 |
+
else:
|
372 |
+
yield "输入路径存在但既不是文件也不是文件夹", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}, {"__type__": "update"}, {"__type__": "update"}
|
373 |
+
return
|
374 |
+
if (ps_slice == []):
|
375 |
+
for i_part in range(n_parts):
|
376 |
+
cmd = '"%s" tools/slice_audio.py "%s" "%s" %s %s %s %s %s %s %s %s %s''' % (python_exec,inp, opt_root, threshold, min_length, min_interval, hop_size, max_sil_kept, _max, alpha, i_part, n_parts)
|
377 |
+
print(cmd)
|
378 |
+
p = Popen(cmd, shell=True)
|
379 |
+
ps_slice.append(p)
|
380 |
+
yield "切割执行中", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}, {"__type__": "update"}, {"__type__": "update"}
|
381 |
+
for p in ps_slice:
|
382 |
+
p.wait()
|
383 |
+
ps_slice=[]
|
384 |
+
yield "切割结束", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}, {"__type__": "update", "value":opt_root}, {"__type__": "update", "value":opt_root}
|
385 |
+
else:
|
386 |
+
yield "已有正在进行的切割任务,需先终止才能开启下一次任务", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}, {"__type__": "update"}, {"__type__": "update"}
|
387 |
+
|
388 |
+
def close_slice():
|
389 |
+
global ps_slice
|
390 |
+
if (ps_slice != []):
|
391 |
+
for p_slice in ps_slice:
|
392 |
+
try:
|
393 |
+
kill_process(p_slice.pid)
|
394 |
+
except:
|
395 |
+
traceback.print_exc()
|
396 |
+
ps_slice=[]
|
397 |
+
return "已终止所有切割进程", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False}
|
398 |
+
|
399 |
+
ps1a=[]
|
400 |
+
def open1a(inp_text,inp_wav_dir,exp_name,gpu_numbers,bert_pretrained_dir):
|
401 |
+
global ps1a
|
402 |
+
inp_text = my_utils.clean_path(inp_text)
|
403 |
+
inp_wav_dir = my_utils.clean_path(inp_wav_dir)
|
404 |
+
if (ps1a == []):
|
405 |
+
opt_dir="%s/%s"%(exp_root,exp_name)
|
406 |
+
config={
|
407 |
+
"inp_text":inp_text,
|
408 |
+
"inp_wav_dir":inp_wav_dir,
|
409 |
+
"exp_name":exp_name,
|
410 |
+
"opt_dir":opt_dir,
|
411 |
+
"bert_pretrained_dir":bert_pretrained_dir,
|
412 |
+
}
|
413 |
+
gpu_names=gpu_numbers.split("-")
|
414 |
+
all_parts=len(gpu_names)
|
415 |
+
for i_part in range(all_parts):
|
416 |
+
config.update(
|
417 |
+
{
|
418 |
+
"i_part": str(i_part),
|
419 |
+
"all_parts": str(all_parts),
|
420 |
+
"_CUDA_VISIBLE_DEVICES": fix_gpu_number(gpu_names[i_part]),
|
421 |
+
"is_half": str(is_half)
|
422 |
+
}
|
423 |
+
)
|
424 |
+
os.environ.update(config)
|
425 |
+
cmd = '"%s" GPT_SoVITS/prepare_datasets/1-get-text.py'%python_exec
|
426 |
+
print(cmd)
|
427 |
+
p = Popen(cmd, shell=True)
|
428 |
+
ps1a.append(p)
|
429 |
+
yield "文本进程执行中", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
430 |
+
for p in ps1a:
|
431 |
+
p.wait()
|
432 |
+
opt = []
|
433 |
+
for i_part in range(all_parts):
|
434 |
+
txt_path = "%s/2-name2text-%s.txt" % (opt_dir, i_part)
|
435 |
+
with open(txt_path, "r", encoding="utf8") as f:
|
436 |
+
opt += f.read().strip("\n").split("\n")
|
437 |
+
os.remove(txt_path)
|
438 |
+
path_text = "%s/2-name2text.txt" % opt_dir
|
439 |
+
with open(path_text, "w", encoding="utf8") as f:
|
440 |
+
f.write("\n".join(opt) + "\n")
|
441 |
+
ps1a=[]
|
442 |
+
if len("".join(opt)) > 0:
|
443 |
+
yield "文本进程成功", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False}
|
444 |
+
else:
|
445 |
+
yield "文本进程失败", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False}
|
446 |
+
else:
|
447 |
+
yield "已有正在进行的文本任务,需先终止才能开启下一次任务", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
448 |
+
|
449 |
+
def close1a():
|
450 |
+
global ps1a
|
451 |
+
if (ps1a != []):
|
452 |
+
for p1a in ps1a:
|
453 |
+
try:
|
454 |
+
kill_process(p1a.pid)
|
455 |
+
except:
|
456 |
+
traceback.print_exc()
|
457 |
+
ps1a=[]
|
458 |
+
return "已终止所有1a进程", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False}
|
459 |
+
|
460 |
+
ps1b=[]
|
461 |
+
def open1b(inp_text,inp_wav_dir,exp_name,gpu_numbers,ssl_pretrained_dir):
|
462 |
+
global ps1b
|
463 |
+
inp_text = my_utils.clean_path(inp_text)
|
464 |
+
inp_wav_dir = my_utils.clean_path(inp_wav_dir)
|
465 |
+
if (ps1b == []):
|
466 |
+
config={
|
467 |
+
"inp_text":inp_text,
|
468 |
+
"inp_wav_dir":inp_wav_dir,
|
469 |
+
"exp_name":exp_name,
|
470 |
+
"opt_dir":"%s/%s"%(exp_root,exp_name),
|
471 |
+
"cnhubert_base_dir":ssl_pretrained_dir,
|
472 |
+
"is_half": str(is_half)
|
473 |
+
}
|
474 |
+
gpu_names=gpu_numbers.split("-")
|
475 |
+
all_parts=len(gpu_names)
|
476 |
+
for i_part in range(all_parts):
|
477 |
+
config.update(
|
478 |
+
{
|
479 |
+
"i_part": str(i_part),
|
480 |
+
"all_parts": str(all_parts),
|
481 |
+
"_CUDA_VISIBLE_DEVICES": fix_gpu_number(gpu_names[i_part]),
|
482 |
+
}
|
483 |
+
)
|
484 |
+
os.environ.update(config)
|
485 |
+
cmd = '"%s" GPT_SoVITS/prepare_datasets/2-get-hubert-wav32k.py'%python_exec
|
486 |
+
print(cmd)
|
487 |
+
p = Popen(cmd, shell=True)
|
488 |
+
ps1b.append(p)
|
489 |
+
yield "SSL提取进程执行中", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
490 |
+
for p in ps1b:
|
491 |
+
p.wait()
|
492 |
+
ps1b=[]
|
493 |
+
yield "SSL提取进程结束", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}
|
494 |
+
else:
|
495 |
+
yield "已有正在进行的SSL提取任务,需先终止才能开启下一次任务", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
496 |
+
|
497 |
+
def close1b():
|
498 |
+
global ps1b
|
499 |
+
if (ps1b != []):
|
500 |
+
for p1b in ps1b:
|
501 |
+
try:
|
502 |
+
kill_process(p1b.pid)
|
503 |
+
except:
|
504 |
+
traceback.print_exc()
|
505 |
+
ps1b=[]
|
506 |
+
return "已终止所有1b进程", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False}
|
507 |
+
|
508 |
+
ps1c=[]
|
509 |
+
def open1c(inp_text,exp_name,gpu_numbers,pretrained_s2G_path):
|
510 |
+
global ps1c
|
511 |
+
inp_text = my_utils.clean_path(inp_text)
|
512 |
+
if (ps1c == []):
|
513 |
+
opt_dir="%s/%s"%(exp_root,exp_name)
|
514 |
+
config={
|
515 |
+
"inp_text":inp_text,
|
516 |
+
"exp_name":exp_name,
|
517 |
+
"opt_dir":opt_dir,
|
518 |
+
"pretrained_s2G":pretrained_s2G_path,
|
519 |
+
"s2config_path":"GPT_SoVITS/configs/s2.json",
|
520 |
+
"is_half": str(is_half)
|
521 |
+
}
|
522 |
+
gpu_names=gpu_numbers.split("-")
|
523 |
+
all_parts=len(gpu_names)
|
524 |
+
for i_part in range(all_parts):
|
525 |
+
config.update(
|
526 |
+
{
|
527 |
+
"i_part": str(i_part),
|
528 |
+
"all_parts": str(all_parts),
|
529 |
+
"_CUDA_VISIBLE_DEVICES": fix_gpu_number(gpu_names[i_part]),
|
530 |
+
}
|
531 |
+
)
|
532 |
+
os.environ.update(config)
|
533 |
+
cmd = '"%s" GPT_SoVITS/prepare_datasets/3-get-semantic.py'%python_exec
|
534 |
+
print(cmd)
|
535 |
+
p = Popen(cmd, shell=True)
|
536 |
+
ps1c.append(p)
|
537 |
+
yield "语义token提取进程执行中", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
538 |
+
for p in ps1c:
|
539 |
+
p.wait()
|
540 |
+
opt = ["item_name\tsemantic_audio"]
|
541 |
+
path_semantic = "%s/6-name2semantic.tsv" % opt_dir
|
542 |
+
for i_part in range(all_parts):
|
543 |
+
semantic_path = "%s/6-name2semantic-%s.tsv" % (opt_dir, i_part)
|
544 |
+
with open(semantic_path, "r", encoding="utf8") as f:
|
545 |
+
opt += f.read().strip("\n").split("\n")
|
546 |
+
os.remove(semantic_path)
|
547 |
+
with open(path_semantic, "w", encoding="utf8") as f:
|
548 |
+
f.write("\n".join(opt) + "\n")
|
549 |
+
ps1c=[]
|
550 |
+
yield "语义token提取进程结束", {"__type__":"update","visible":True}, {"__type__":"update","visible":False}
|
551 |
+
else:
|
552 |
+
yield "已有正在进行的语义token提取任务,需先终止才能开启下一次任务", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
553 |
+
|
554 |
+
def close1c():
|
555 |
+
global ps1c
|
556 |
+
if (ps1c != []):
|
557 |
+
for p1c in ps1c:
|
558 |
+
try:
|
559 |
+
kill_process(p1c.pid)
|
560 |
+
except:
|
561 |
+
traceback.print_exc()
|
562 |
+
ps1c=[]
|
563 |
+
return "已终止所有语义token进程", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False}
|
564 |
+
#####inp_text,inp_wav_dir,exp_name,gpu_numbers1a,gpu_numbers1Ba,gpu_numbers1c,bert_pretrained_dir,cnhubert_base_dir,pretrained_s2G
|
565 |
+
ps1abc=[]
|
566 |
+
def open1abc(inp_text,inp_wav_dir,exp_name,gpu_numbers1a,gpu_numbers1Ba,gpu_numbers1c,bert_pretrained_dir,ssl_pretrained_dir,pretrained_s2G_path):
|
567 |
+
global ps1abc
|
568 |
+
inp_text = my_utils.clean_path(inp_text)
|
569 |
+
inp_wav_dir = my_utils.clean_path(inp_wav_dir)
|
570 |
+
if (ps1abc == []):
|
571 |
+
opt_dir="%s/%s"%(exp_root,exp_name)
|
572 |
+
try:
|
573 |
+
#############################1a
|
574 |
+
path_text="%s/2-name2text.txt" % opt_dir
|
575 |
+
if(os.path.exists(path_text)==False or (os.path.exists(path_text)==True and len(open(path_text,"r",encoding="utf8").read().strip("\n").split("\n"))<2)):
|
576 |
+
config={
|
577 |
+
"inp_text":inp_text,
|
578 |
+
"inp_wav_dir":inp_wav_dir,
|
579 |
+
"exp_name":exp_name,
|
580 |
+
"opt_dir":opt_dir,
|
581 |
+
"bert_pretrained_dir":bert_pretrained_dir,
|
582 |
+
"is_half": str(is_half)
|
583 |
+
}
|
584 |
+
gpu_names=gpu_numbers1a.split("-")
|
585 |
+
all_parts=len(gpu_names)
|
586 |
+
for i_part in range(all_parts):
|
587 |
+
config.update(
|
588 |
+
{
|
589 |
+
"i_part": str(i_part),
|
590 |
+
"all_parts": str(all_parts),
|
591 |
+
"_CUDA_VISIBLE_DEVICES": fix_gpu_number(gpu_names[i_part]),
|
592 |
+
}
|
593 |
+
)
|
594 |
+
os.environ.update(config)
|
595 |
+
cmd = '"%s" GPT_SoVITS/prepare_datasets/1-get-text.py'%python_exec
|
596 |
+
print(cmd)
|
597 |
+
p = Popen(cmd, shell=True)
|
598 |
+
ps1abc.append(p)
|
599 |
+
yield "进度:1a-ing", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
600 |
+
for p in ps1abc:p.wait()
|
601 |
+
|
602 |
+
opt = []
|
603 |
+
for i_part in range(all_parts):#txt_path="%s/2-name2text-%s.txt"%(opt_dir,i_part)
|
604 |
+
txt_path = "%s/2-name2text-%s.txt" % (opt_dir, i_part)
|
605 |
+
with open(txt_path, "r",encoding="utf8") as f:
|
606 |
+
opt += f.read().strip("\n").split("\n")
|
607 |
+
os.remove(txt_path)
|
608 |
+
with open(path_text, "w",encoding="utf8") as f:
|
609 |
+
f.write("\n".join(opt) + "\n")
|
610 |
+
assert len("".join(opt)) > 0, "1Aa-文本获取进程失败"
|
611 |
+
yield "进度:1a-done", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
612 |
+
ps1abc=[]
|
613 |
+
#############################1b
|
614 |
+
config={
|
615 |
+
"inp_text":inp_text,
|
616 |
+
"inp_wav_dir":inp_wav_dir,
|
617 |
+
"exp_name":exp_name,
|
618 |
+
"opt_dir":opt_dir,
|
619 |
+
"cnhubert_base_dir":ssl_pretrained_dir,
|
620 |
+
}
|
621 |
+
gpu_names=gpu_numbers1Ba.split("-")
|
622 |
+
all_parts=len(gpu_names)
|
623 |
+
for i_part in range(all_parts):
|
624 |
+
config.update(
|
625 |
+
{
|
626 |
+
"i_part": str(i_part),
|
627 |
+
"all_parts": str(all_parts),
|
628 |
+
"_CUDA_VISIBLE_DEVICES": fix_gpu_number(gpu_names[i_part]),
|
629 |
+
}
|
630 |
+
)
|
631 |
+
os.environ.update(config)
|
632 |
+
cmd = '"%s" GPT_SoVITS/prepare_datasets/2-get-hubert-wav32k.py'%python_exec
|
633 |
+
print(cmd)
|
634 |
+
p = Popen(cmd, shell=True)
|
635 |
+
ps1abc.append(p)
|
636 |
+
yield "进度:1a-done, 1b-ing", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
637 |
+
for p in ps1abc:p.wait()
|
638 |
+
yield "进度:1a1b-done", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
639 |
+
ps1abc=[]
|
640 |
+
#############################1c
|
641 |
+
path_semantic = "%s/6-name2semantic.tsv" % opt_dir
|
642 |
+
if(os.path.exists(path_semantic)==False or (os.path.exists(path_semantic)==True and os.path.getsize(path_semantic)<31)):
|
643 |
+
config={
|
644 |
+
"inp_text":inp_text,
|
645 |
+
"exp_name":exp_name,
|
646 |
+
"opt_dir":opt_dir,
|
647 |
+
"pretrained_s2G":pretrained_s2G_path,
|
648 |
+
"s2config_path":"GPT_SoVITS/configs/s2.json",
|
649 |
+
}
|
650 |
+
gpu_names=gpu_numbers1c.split("-")
|
651 |
+
all_parts=len(gpu_names)
|
652 |
+
for i_part in range(all_parts):
|
653 |
+
config.update(
|
654 |
+
{
|
655 |
+
"i_part": str(i_part),
|
656 |
+
"all_parts": str(all_parts),
|
657 |
+
"_CUDA_VISIBLE_DEVICES": fix_gpu_number(gpu_names[i_part]),
|
658 |
+
}
|
659 |
+
)
|
660 |
+
os.environ.update(config)
|
661 |
+
cmd = '"%s" GPT_SoVITS/prepare_datasets/3-get-semantic.py'%python_exec
|
662 |
+
print(cmd)
|
663 |
+
p = Popen(cmd, shell=True)
|
664 |
+
ps1abc.append(p)
|
665 |
+
yield "进度:1a1b-done, 1cing", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
666 |
+
for p in ps1abc:p.wait()
|
667 |
+
|
668 |
+
opt = ["item_name\tsemantic_audio"]
|
669 |
+
for i_part in range(all_parts):
|
670 |
+
semantic_path = "%s/6-name2semantic-%s.tsv" % (opt_dir, i_part)
|
671 |
+
with open(semantic_path, "r",encoding="utf8") as f:
|
672 |
+
opt += f.read().strip("\n").split("\n")
|
673 |
+
os.remove(semantic_path)
|
674 |
+
with open(path_semantic, "w",encoding="utf8") as f:
|
675 |
+
f.write("\n".join(opt) + "\n")
|
676 |
+
yield "进度:all-done", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
677 |
+
ps1abc = []
|
678 |
+
yield "一键三连进程结束", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False}
|
679 |
+
except:
|
680 |
+
traceback.print_exc()
|
681 |
+
close1abc()
|
682 |
+
yield "一键三连中途报错", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False}
|
683 |
+
else:
|
684 |
+
yield "已有正在进行的一键三连任务,需先终止才能开启下一次任务", {"__type__": "update", "visible": False}, {"__type__": "update", "visible": True}
|
685 |
+
|
686 |
+
def close1abc():
|
687 |
+
global ps1abc
|
688 |
+
if (ps1abc != []):
|
689 |
+
for p1abc in ps1abc:
|
690 |
+
try:
|
691 |
+
kill_process(p1abc.pid)
|
692 |
+
except:
|
693 |
+
traceback.print_exc()
|
694 |
+
ps1abc=[]
|
695 |
+
return "已终止所有一键三连进程", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False}
|
696 |
+
|
697 |
+
with gr.Blocks(title="GPT-SoVITS WebUI") as app:
|
698 |
+
gr.Markdown(
|
699 |
+
value=
|
700 |
+
i18n("本软件以MIT协议开源, 作者不对软件具备任何控制力, 使用软件者、传播软件导出的声音者自负全责. <br>如不认可该条款, 则不能使用或引用软件包内任何代码和文件. 详见根目录<b>LICENSE</b>.")
|
701 |
+
)
|
702 |
+
gr.Markdown(
|
703 |
+
value=
|
704 |
+
i18n("中文教程文档:https://www.yuque.com/baicaigongchang1145haoyuangong/ib3g1e")
|
705 |
+
)
|
706 |
+
|
707 |
+
with gr.Tabs():
|
708 |
+
with gr.TabItem(i18n("0-前置数据集获取工具")):#提前随机切片防止uvr5爆内存->uvr5->slicer->asr->打标
|
709 |
+
gr.Markdown(value=i18n("0a-UVR5人声伴奏分离&去混响去延迟工具"))
|
710 |
+
with gr.Row():
|
711 |
+
if_uvr5 = gr.Checkbox(label=i18n("是否开启UVR5-WebUI"),show_label=True)
|
712 |
+
uvr5_info = gr.Textbox(label=i18n("UVR5进程输出信息"))
|
713 |
+
gr.Markdown(value=i18n("0b-语音切分工具"))
|
714 |
+
with gr.Row():
|
715 |
+
with gr.Column(scale=3):
|
716 |
+
with gr.Row():
|
717 |
+
slice_inp_path=gr.Textbox(label=i18n("音频自动切分输入路径,可文件可文件夹"),value="")
|
718 |
+
slice_opt_root=gr.Textbox(label=i18n("切分后的子音频的输出根目录"),value="output/slicer_opt")
|
719 |
+
with gr.Row():
|
720 |
+
threshold=gr.Textbox(label=i18n("threshold:音量小于这个值视作静音的备选切割点"),value="-34")
|
721 |
+
min_length=gr.Textbox(label=i18n("min_length:每段最小多长,如果第一段太短一直和后面段连起来直到超过这个值"),value="4000")
|
722 |
+
min_interval=gr.Textbox(label=i18n("min_interval:最短切割间隔"),value="300")
|
723 |
+
hop_size=gr.Textbox(label=i18n("hop_size:怎么算音量曲线,越小精度越大计算量越高(不是精度越大效果越好)"),value="10")
|
724 |
+
max_sil_kept=gr.Textbox(label=i18n("max_sil_kept:切完后静音最多留多长"),value="500")
|
725 |
+
with gr.Row():
|
726 |
+
_max=gr.Slider(minimum=0,maximum=1,step=0.05,label=i18n("max:归一化后最大值多少"),value=0.9,interactive=True)
|
727 |
+
alpha=gr.Slider(minimum=0,maximum=1,step=0.05,label=i18n("alpha_mix:混多少比例归一化后音频进来"),value=0.25,interactive=True)
|
728 |
+
n_process=gr.Slider(minimum=1,maximum=n_cpu,step=1,label=i18n("切割使用的进程数"),value=4,interactive=True)
|
729 |
+
with gr.Row():
|
730 |
+
slicer_info = gr.Textbox(label=i18n("语音切割进程输出信息"))
|
731 |
+
open_slicer_button=gr.Button(i18n("开启语音切割"), variant="primary",visible=True)
|
732 |
+
close_slicer_button=gr.Button(i18n("终止语音切割"), variant="primary",visible=False)
|
733 |
+
gr.Markdown(value=i18n("0bb-语音降噪工具"))
|
734 |
+
with gr.Row():
|
735 |
+
with gr.Column(scale=3):
|
736 |
+
with gr.Row():
|
737 |
+
denoise_input_dir=gr.Textbox(label=i18n("降噪音频文件输入文件夹"),value="")
|
738 |
+
denoise_output_dir=gr.Textbox(label=i18n("降噪结果输出文件夹"),value="output/denoise_opt")
|
739 |
+
with gr.Row():
|
740 |
+
denoise_info = gr.Textbox(label=i18n("语音降噪进程输出信息"))
|
741 |
+
open_denoise_button = gr.Button(i18n("开启语音降噪"), variant="primary",visible=True)
|
742 |
+
close_denoise_button = gr.Button(i18n("终止语音降噪进程"), variant="primary",visible=False)
|
743 |
+
gr.Markdown(value=i18n("0c-中文批量离线ASR工具"))
|
744 |
+
with gr.Row():
|
745 |
+
with gr.Column(scale=3):
|
746 |
+
with gr.Row():
|
747 |
+
asr_inp_dir = gr.Textbox(
|
748 |
+
label=i18n("输入文件夹路径"),
|
749 |
+
value="D:\\GPT-SoVITS\\raw\\xxx",
|
750 |
+
interactive=True,
|
751 |
+
)
|
752 |
+
asr_opt_dir = gr.Textbox(
|
753 |
+
label = i18n("输出文件夹路径"),
|
754 |
+
value = "output/asr_opt",
|
755 |
+
interactive = True,
|
756 |
+
)
|
757 |
+
with gr.Row():
|
758 |
+
asr_model = gr.Dropdown(
|
759 |
+
label = i18n("ASR 模型"),
|
760 |
+
choices = list(asr_dict.keys()),
|
761 |
+
interactive = True,
|
762 |
+
value="达摩 ASR (中文)"
|
763 |
+
)
|
764 |
+
asr_size = gr.Dropdown(
|
765 |
+
label = i18n("ASR 模型尺寸"),
|
766 |
+
choices = ["large"],
|
767 |
+
interactive = True,
|
768 |
+
value="large"
|
769 |
+
)
|
770 |
+
asr_lang = gr.Dropdown(
|
771 |
+
label = i18n("ASR 语言设置"),
|
772 |
+
choices = ["zh"],
|
773 |
+
interactive = True,
|
774 |
+
value="zh"
|
775 |
+
)
|
776 |
+
asr_precision = gr.Dropdown(
|
777 |
+
label = i18n("数据类型精度"),
|
778 |
+
choices = ["float32"],
|
779 |
+
interactive = True,
|
780 |
+
value="float32"
|
781 |
+
)
|
782 |
+
with gr.Row():
|
783 |
+
asr_info = gr.Textbox(label=i18n("ASR进程输出信息"))
|
784 |
+
open_asr_button = gr.Button(i18n("开启离线批量ASR"), variant="primary",visible=True)
|
785 |
+
close_asr_button = gr.Button(i18n("终止ASR进程"), variant="primary",visible=False)
|
786 |
+
|
787 |
+
def change_lang_choices(key): #根据选择的模型修改可选的语言
|
788 |
+
# return gr.Dropdown(choices=asr_dict[key]['lang'])
|
789 |
+
return {"__type__": "update", "choices": asr_dict[key]['lang'],"value":asr_dict[key]['lang'][0]}
|
790 |
+
def change_size_choices(key): # 根据选择的模型修改可选的模型尺寸
|
791 |
+
# return gr.Dropdown(choices=asr_dict[key]['size'])
|
792 |
+
return {"__type__": "update", "choices": asr_dict[key]['size'],"value":asr_dict[key]['size'][-1]}
|
793 |
+
def change_precision_choices(key): #根据选择的模型修改可选的语言
|
794 |
+
if key =="Faster Whisper (多语种)":
|
795 |
+
if default_batch_size <= 4:
|
796 |
+
precision = 'int8'
|
797 |
+
elif is_half:
|
798 |
+
precision = 'float16'
|
799 |
+
else:
|
800 |
+
precision = 'float32'
|
801 |
+
else:
|
802 |
+
precision = 'float32'
|
803 |
+
# return gr.Dropdown(choices=asr_dict[key]['precision'])
|
804 |
+
return {"__type__": "update", "choices": asr_dict[key]['precision'],"value":precision}
|
805 |
+
asr_model.change(change_lang_choices, [asr_model], [asr_lang])
|
806 |
+
asr_model.change(change_size_choices, [asr_model], [asr_size])
|
807 |
+
asr_model.change(change_precision_choices, [asr_model], [asr_precision])
|
808 |
+
|
809 |
+
|
810 |
+
gr.Markdown(value=i18n("0d-语音文本校对标注工具"))
|
811 |
+
with gr.Row():
|
812 |
+
if_label = gr.Checkbox(label=i18n("是否开启打标WebUI"),show_label=True)
|
813 |
+
path_list = gr.Textbox(
|
814 |
+
label=i18n(".list标注文件的路径"),
|
815 |
+
value="D:\\RVC1006\\GPT-SoVITS\\raw\\xxx.list",
|
816 |
+
interactive=True,
|
817 |
+
)
|
818 |
+
label_info = gr.Textbox(label=i18n("打标工具进程输出信息"))
|
819 |
+
if_label.change(change_label, [if_label,path_list], [label_info])
|
820 |
+
if_uvr5.change(change_uvr5, [if_uvr5], [uvr5_info])
|
821 |
+
open_asr_button.click(open_asr, [asr_inp_dir, asr_opt_dir, asr_model, asr_size, asr_lang, asr_precision], [asr_info,open_asr_button,close_asr_button,path_list])
|
822 |
+
close_asr_button.click(close_asr, [], [asr_info,open_asr_button,close_asr_button])
|
823 |
+
open_slicer_button.click(open_slice, [slice_inp_path,slice_opt_root,threshold,min_length,min_interval,hop_size,max_sil_kept,_max,alpha,n_process], [slicer_info,open_slicer_button,close_slicer_button,asr_inp_dir,denoise_input_dir])
|
824 |
+
close_slicer_button.click(close_slice, [], [slicer_info,open_slicer_button,close_slicer_button])
|
825 |
+
open_denoise_button.click(open_denoise, [denoise_input_dir,denoise_output_dir], [denoise_info,open_denoise_button,close_denoise_button,asr_inp_dir])
|
826 |
+
close_denoise_button.click(close_denoise, [], [denoise_info,open_denoise_button,close_denoise_button])
|
827 |
+
|
828 |
+
with gr.TabItem(i18n("1-GPT-SoVITS-TTS")):
|
829 |
+
with gr.Row():
|
830 |
+
exp_name = gr.Textbox(label=i18n("*实验/模型名"), value="xxx", interactive=True)
|
831 |
+
gpu_info = gr.Textbox(label=i18n("显卡信息"), value=gpu_info, visible=True, interactive=False)
|
832 |
+
pretrained_s2G = gr.Textbox(label=i18n("预训练的SoVITS-G模型路径"), value=pretrained_sovits_name, interactive=True)
|
833 |
+
pretrained_s2D = gr.Textbox(label=i18n("预训练的SoVITS-D模型路径"), value=pretrained_sovits_name.replace("s2G","s2D"), interactive=True)
|
834 |
+
pretrained_s1 = gr.Textbox(label=i18n("预训练的GPT模型路径"), value=pretrained_gpt_name, interactive=True)
|
835 |
+
with gr.TabItem(i18n("1A-训练集格式化工具")):
|
836 |
+
gr.Markdown(value=i18n("输出logs/实验名目录下应有23456开头的文件和文件夹"))
|
837 |
+
with gr.Row():
|
838 |
+
inp_text = gr.Textbox(label=i18n("*文本标注文件"),value=r"D:\RVC1006\GPT-SoVITS\raw\xxx.list",interactive=True)
|
839 |
+
inp_wav_dir = gr.Textbox(
|
840 |
+
label=i18n("*训练集音频文件目录"),
|
841 |
+
# value=r"D:\RVC1006\GPT-SoVITS\raw\xxx",
|
842 |
+
interactive=True,
|
843 |
+
placeholder=i18n("填切割后音频所在目录!读取的音频文件完整路径=该目录-拼接-list文件里波形对应的文件名(不是全路径)。如果留空则使用.list文件里的绝对全路径。")
|
844 |
+
)
|
845 |
+
gr.Markdown(value=i18n("1Aa-文本内容"))
|
846 |
+
with gr.Row():
|
847 |
+
gpu_numbers1a = gr.Textbox(label=i18n("GPU卡号以-分割,每个卡号一个进程"),value="%s-%s"%(gpus,gpus),interactive=True)
|
848 |
+
bert_pretrained_dir = gr.Textbox(label=i18n("预训练的中文BERT模型路径"),value="GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large",interactive=False)
|
849 |
+
button1a_open = gr.Button(i18n("开启文本获取"), variant="primary",visible=True)
|
850 |
+
button1a_close = gr.Button(i18n("终止文本获取进程"), variant="primary",visible=False)
|
851 |
+
info1a=gr.Textbox(label=i18n("文本进程输出信息"))
|
852 |
+
gr.Markdown(value=i18n("1Ab-SSL自监督特征提取"))
|
853 |
+
with gr.Row():
|
854 |
+
gpu_numbers1Ba = gr.Textbox(label=i18n("GPU卡号以-分割,每个卡号一个进程"),value="%s-%s"%(gpus,gpus),interactive=True)
|
855 |
+
cnhubert_base_dir = gr.Textbox(label=i18n("预训练的SSL模型路径"),value="GPT_SoVITS/pretrained_models/chinese-hubert-base",interactive=False)
|
856 |
+
button1b_open = gr.Button(i18n("开启SSL提取"), variant="primary",visible=True)
|
857 |
+
button1b_close = gr.Button(i18n("终止SSL提取进程"), variant="primary",visible=False)
|
858 |
+
info1b=gr.Textbox(label=i18n("SSL进程输出信息"))
|
859 |
+
gr.Markdown(value=i18n("1Ac-语义token提取"))
|
860 |
+
with gr.Row():
|
861 |
+
gpu_numbers1c = gr.Textbox(label=i18n("GPU卡号以-分割,每个卡号一个进程"),value="%s-%s"%(gpus,gpus),interactive=True)
|
862 |
+
button1c_open = gr.Button(i18n("开启语义token提取"), variant="primary",visible=True)
|
863 |
+
button1c_close = gr.Button(i18n("终止语义token提取进程"), variant="primary",visible=False)
|
864 |
+
info1c=gr.Textbox(label=i18n("语义token提取进程输出信息"))
|
865 |
+
gr.Markdown(value=i18n("1Aabc-训练集格式化一键三连"))
|
866 |
+
with gr.Row():
|
867 |
+
button1abc_open = gr.Button(i18n("开启一键三连"), variant="primary",visible=True)
|
868 |
+
button1abc_close = gr.Button(i18n("终止一键三连"), variant="primary",visible=False)
|
869 |
+
info1abc=gr.Textbox(label=i18n("一键三连进程输出信息"))
|
870 |
+
button1a_open.click(open1a, [inp_text,inp_wav_dir,exp_name,gpu_numbers1a,bert_pretrained_dir], [info1a,button1a_open,button1a_close])
|
871 |
+
button1a_close.click(close1a, [], [info1a,button1a_open,button1a_close])
|
872 |
+
button1b_open.click(open1b, [inp_text,inp_wav_dir,exp_name,gpu_numbers1Ba,cnhubert_base_dir], [info1b,button1b_open,button1b_close])
|
873 |
+
button1b_close.click(close1b, [], [info1b,button1b_open,button1b_close])
|
874 |
+
button1c_open.click(open1c, [inp_text,exp_name,gpu_numbers1c,pretrained_s2G], [info1c,button1c_open,button1c_close])
|
875 |
+
button1c_close.click(close1c, [], [info1c,button1c_open,button1c_close])
|
876 |
+
button1abc_open.click(open1abc, [inp_text,inp_wav_dir,exp_name,gpu_numbers1a,gpu_numbers1Ba,gpu_numbers1c,bert_pretrained_dir,cnhubert_base_dir,pretrained_s2G], [info1abc,button1abc_open,button1abc_close])
|
877 |
+
button1abc_close.click(close1abc, [], [info1abc,button1abc_open,button1abc_close])
|
878 |
+
with gr.TabItem(i18n("1B-微调训练")):
|
879 |
+
gr.Markdown(value=i18n("1Ba-SoVITS训练。用于分享的模型文件输出在SoVITS_weights下。"))
|
880 |
+
with gr.Row():
|
881 |
+
batch_size = gr.Slider(minimum=1,maximum=40,step=1,label=i18n("每张显卡的batch_size"),value=default_batch_size,interactive=True)
|
882 |
+
total_epoch = gr.Slider(minimum=1,maximum=25,step=1,label=i18n("总训练轮数total_epoch,不建议太高"),value=8,interactive=True)
|
883 |
+
text_low_lr_rate = gr.Slider(minimum=0.2,maximum=0.6,step=0.05,label=i18n("文本模块学习率权重"),value=0.4,interactive=True)
|
884 |
+
save_every_epoch = gr.Slider(minimum=1,maximum=25,step=1,label=i18n("保存频率save_every_epoch"),value=4,interactive=True)
|
885 |
+
if_save_latest = gr.Checkbox(label=i18n("是否仅保存最新的ckpt文件以节省硬盘空间"), value=True, interactive=True, show_label=True)
|
886 |
+
if_save_every_weights = gr.Checkbox(label=i18n("是否在每次保存时间点将最终小模型保存至weights文件夹"), value=True, interactive=True, show_label=True)
|
887 |
+
gpu_numbers1Ba = gr.Textbox(label=i18n("GPU卡号以-分割,每个卡号一个进程"), value="%s" % (gpus), interactive=True)
|
888 |
+
with gr.Row():
|
889 |
+
button1Ba_open = gr.Button(i18n("开启SoVITS训练"), variant="primary",visible=True)
|
890 |
+
button1Ba_close = gr.Button(i18n("终止SoVITS训练"), variant="primary",visible=False)
|
891 |
+
info1Ba=gr.Textbox(label=i18n("SoVITS训练进程输出信息"))
|
892 |
+
gr.Markdown(value=i18n("1Bb-GPT训练。用于分享的模型文件输出在GPT_weights下。"))
|
893 |
+
with gr.Row():
|
894 |
+
batch_size1Bb = gr.Slider(minimum=1,maximum=40,step=1,label=i18n("每张显卡的batch_size"),value=default_batch_size,interactive=True)
|
895 |
+
total_epoch1Bb = gr.Slider(minimum=2,maximum=50,step=1,label=i18n("总训练轮数total_epoch"),value=15,interactive=True)
|
896 |
+
if_dpo = gr.Checkbox(label=i18n("是否开启dpo训练选项(实验性)"), value=False, interactive=True, show_label=True)
|
897 |
+
if_save_latest1Bb = gr.Checkbox(label=i18n("是否仅保存最新的ckpt文件以节省硬盘空间"), value=True, interactive=True, show_label=True)
|
898 |
+
if_save_every_weights1Bb = gr.Checkbox(label=i18n("是否在每次保存时间点将最终小模型保存至weights文件夹"), value=True, interactive=True, show_label=True)
|
899 |
+
save_every_epoch1Bb = gr.Slider(minimum=1,maximum=50,step=1,label=i18n("保存频率save_every_epoch"),value=5,interactive=True)
|
900 |
+
gpu_numbers1Bb = gr.Textbox(label=i18n("GPU卡号以-分割,每个卡号一个进程"), value="%s" % (gpus), interactive=True)
|
901 |
+
with gr.Row():
|
902 |
+
button1Bb_open = gr.Button(i18n("开启GPT训练"), variant="primary",visible=True)
|
903 |
+
button1Bb_close = gr.Button(i18n("终止GPT训练"), variant="primary",visible=False)
|
904 |
+
info1Bb=gr.Textbox(label=i18n("GPT训练进程输出信息"))
|
905 |
+
button1Ba_open.click(open1Ba, [batch_size,total_epoch,exp_name,text_low_lr_rate,if_save_latest,if_save_every_weights,save_every_epoch,gpu_numbers1Ba,pretrained_s2G,pretrained_s2D], [info1Ba,button1Ba_open,button1Ba_close])
|
906 |
+
button1Ba_close.click(close1Ba, [], [info1Ba,button1Ba_open,button1Ba_close])
|
907 |
+
button1Bb_open.click(open1Bb, [batch_size1Bb,total_epoch1Bb,exp_name,if_dpo,if_save_latest1Bb,if_save_every_weights1Bb,save_every_epoch1Bb,gpu_numbers1Bb,pretrained_s1], [info1Bb,button1Bb_open,button1Bb_close])
|
908 |
+
button1Bb_close.click(close1Bb, [], [info1Bb,button1Bb_open,button1Bb_close])
|
909 |
+
with gr.TabItem(i18n("1C-推理")):
|
910 |
+
gr.Markdown(value=i18n("选择训练完存放在SoVITS_weights和GPT_weights下的模型。默认的一个是底模,体验5秒Zero Shot TTS用。"))
|
911 |
+
with gr.Row():
|
912 |
+
GPT_dropdown = gr.Dropdown(label=i18n("*GPT模型列表"), choices=sorted(GPT_names,key=custom_sort_key),value=pretrained_gpt_name,interactive=True)
|
913 |
+
SoVITS_dropdown = gr.Dropdown(label=i18n("*SoVITS模型列表"), choices=sorted(SoVITS_names,key=custom_sort_key),value=pretrained_sovits_name,interactive=True)
|
914 |
+
gpu_number_1C=gr.Textbox(label=i18n("GPU卡号,只能填1个整数"), value=gpus, interactive=True)
|
915 |
+
refresh_button = gr.Button(i18n("刷新模型路径"), variant="primary")
|
916 |
+
refresh_button.click(fn=change_choices,inputs=[],outputs=[SoVITS_dropdown,GPT_dropdown])
|
917 |
+
with gr.Row():
|
918 |
+
if_tts = gr.Checkbox(label=i18n("是否开启TTS推理WebUI"), show_label=True)
|
919 |
+
tts_info = gr.Textbox(label=i18n("TTS推理WebUI进程输出信息"))
|
920 |
+
if_tts.change(change_tts_inference, [if_tts,bert_pretrained_dir,cnhubert_base_dir,gpu_number_1C,GPT_dropdown,SoVITS_dropdown], [tts_info])
|
921 |
+
with gr.TabItem(i18n("2-GPT-SoVITS-变声")):gr.Markdown(value=i18n("施工中,请静候佳音"))
|
922 |
+
# app.queue(concurrency_count=511, max_size=1022).launch(
|
923 |
+
# server_name="0.0.0.0",
|
924 |
+
# inbrowser=True,
|
925 |
+
# share=is_share,
|
926 |
+
# server_port=webui_port_main,
|
927 |
+
# quiet=True,
|
928 |
+
# )
|
929 |
+
# button1abc_open.click(open1abc, [inp_text,inp_wav_dir,exp_name,gpu_numbers1a,gpu_numbers1Ba,gpu_numbers1c,bert_pretrained_dir,cnhubert_base_dir,pretrained_s2G], [info1abc,button1abc_open,button1abc_close])
|
930 |
+
# open1abc(./*/transcript.txt, None, *, "0-1", "0-1", "0-1", "GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large", "GPT_SoVITS/pretrained_models/chinese-hubert-base", "GPT_SoVITS/pretrained_models/s2G2333k.pth")
|
931 |
+
|
932 |
import os
|
933 |
import sys
|
934 |
# to avoid the modified user.pth file
|