More and More Chores

This commit is contained in:
XXXXRT666 2024-08-06 02:02:26 +08:00
parent abc47f14e9
commit c431ced520
3 changed files with 142 additions and 110 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
.DS_Store .DS_Store
.vscode
__pycache__ __pycache__
*.pyc *.pyc
env env

View File

@ -18,12 +18,19 @@ import LangSegment, os, re, sys, json
import pdb import pdb
import torch import torch
if len(sys.argv)==1:sys.argv.append('v1') version=os.environ.get("version","v2")
version=os.environ.get("version","v1") pretrained_sovits_name=["GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth", "GPT_SoVITS/pretrained_models/s2G488k.pth"]
version="v2"if sys.argv[1]=="v2" else version pretrained_gpt_name=["GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt", "GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt"]
os.environ['version']=version
pretrained_sovits_name="GPT_SoVITS/pretrained_models/s2G488k.pth"if version=="v1"else"GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth" _ =[[],[]]
pretrained_gpt_name="GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt"if version=="v1"else "GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt" for i in range(2):
if os.path.exists(pretrained_gpt_name[i]):
_[0].append(pretrained_gpt_name[i])
if os.path.exists(pretrained_sovits_name[i]):
_[-1].append(pretrained_sovits_name[i])
pretrained_gpt_name,pretrained_sovits_name = _
if os.path.exists(f"./weight.json"): if os.path.exists(f"./weight.json"):
pass pass
@ -37,6 +44,10 @@ with open(f"./weight.json", 'r', encoding="utf-8") as file:
"gpt_path", weight_data.get('GPT',{}).get(version,pretrained_gpt_name)) "gpt_path", weight_data.get('GPT',{}).get(version,pretrained_gpt_name))
sovits_path = os.environ.get( sovits_path = os.environ.get(
"sovits_path", weight_data.get('SoVITS',{}).get(version,pretrained_sovits_name)) "sovits_path", weight_data.get('SoVITS',{}).get(version,pretrained_sovits_name))
if isinstance(gpt_path,list):
gpt_path = gpt_path[0]
if isinstance(sovits_path,list):
sovits_path = sovits_path[0]
# gpt_path = os.environ.get( # gpt_path = os.environ.get(
# "gpt_path", pretrained_gpt_name # "gpt_path", pretrained_gpt_name
@ -87,6 +98,29 @@ if torch.cuda.is_available():
else: else:
device = "cpu" device = "cpu"
dict_language_v1 = {
i18n("中文"): "all_zh",#全部按中文识别
i18n("英文"): "en",#全部按英文识别#######不变
i18n("日文"): "all_ja",#全部按日文识别
i18n("中英混合"): "zh",#按中英混合识别####不变
i18n("日英混合"): "ja",#按日英混合识别####不变
i18n("多语种混合"): "auto",#多语种启动切分识别语种
}
dict_language_v2 = {
i18n("中文"): "all_zh",#全部按中文识别
i18n("英文"): "en",#全部按英文识别#######不变
i18n("日文"): "all_ja",#全部按日文识别
i18n("粤语"): "all_yue",#全部按中文识别
i18n("韩文"): "all_ko",#全部按韩文识别
i18n("中英混合"): "zh",#按中英混合识别####不变
i18n("日英混合"): "ja",#按日英混合识别####不变
i18n("粤英混合"): "yue",#按粤英混合识别####不变
i18n("韩英混合"): "ko",#按韩英混合识别####不变
i18n("多语种混合"): "auto",#多语种启动切分识别语种
i18n("多语种混合(粤语)"): "auto_yue",#多语种启动切分识别语种
}
dict_language = dict_language_v1 if version =='v1' else dict_language_v2
tokenizer = AutoTokenizer.from_pretrained(bert_path) tokenizer = AutoTokenizer.from_pretrained(bert_path)
bert_model = AutoModelForMaskedLM.from_pretrained(bert_path) bert_model = AutoModelForMaskedLM.from_pretrained(bert_path)
if is_half == True: if is_half == True:
@ -146,8 +180,8 @@ else:
ssl_model = ssl_model.to(device) ssl_model = ssl_model.to(device)
def change_sovits_weights(sovits_path): def change_sovits_weights(sovits_path,prompt_language=None,text_language=None):
global vq_model, hps global vq_model, hps, version, dict_language
dict_s2 = torch.load(sovits_path, map_location="cpu") dict_s2 = torch.load(sovits_path, map_location="cpu")
hps = dict_s2["config"] hps = dict_s2["config"]
hps = DictToAttrRecursive(hps) hps = DictToAttrRecursive(hps)
@ -156,6 +190,7 @@ def change_sovits_weights(sovits_path):
hps.model.version = "v1" hps.model.version = "v1"
else: else:
hps.model.version = "v2" hps.model.version = "v2"
version = hps.model.version
# print("sovits版本:",hps.model.version) # print("sovits版本:",hps.model.version)
vq_model = SynthesizerTrn( vq_model = SynthesizerTrn(
hps.data.filter_length // 2 + 1, hps.data.filter_length // 2 + 1,
@ -171,11 +206,25 @@ def change_sovits_weights(sovits_path):
vq_model = vq_model.to(device) vq_model = vq_model.to(device)
vq_model.eval() vq_model.eval()
print(vq_model.load_state_dict(dict_s2["weight"], strict=False)) print(vq_model.load_state_dict(dict_s2["weight"], strict=False))
dict_language = dict_language_v1 if version =='v1' else dict_language_v2
with open("./weight.json")as f: with open("./weight.json")as f:
data=f.read() data=f.read()
data=json.loads(data) data=json.loads(data)
data["SoVITS"][version]=sovits_path data["SoVITS"][version]=sovits_path
with open("./weight.json","w")as f:f.write(json.dumps(data)) with open("./weight.json","w")as f:f.write(json.dumps(data))
if prompt_language is not None and text_language is not None:
if prompt_language in list(dict_language.keys()):
prompt_text_update, prompt_language_update = {'__type__':'update'}, {'__type__':'update', 'value':prompt_language}
else:
prompt_text_update = {'__type__':'update', 'value':''}
prompt_language_update = {'__type__':'update', 'value':i18n("中文")}
if text_language in list(dict_language.keys()):
text_update, text_language_update = {'__type__':'update'}, {'__type__':'update', 'value':text_language}
else:
text_update = {'__type__':'update', 'value':''}
text_language_update = {'__type__':'update', 'value':i18n("中文")}
return {'__type__':'update', 'choices':list(dict_language.keys())}, {'__type__':'update', 'choices':list(dict_language.keys())}, prompt_text_update, prompt_language_update, text_update, text_language_update
change_sovits_weights(sovits_path) change_sovits_weights(sovits_path)
@ -220,29 +269,6 @@ def get_spepc(hps, filename):
) )
return spec return spec
dict_language_v1 = {
i18n("中文"): "all_zh",#全部按中文识别
i18n("英文"): "en",#全部按英文识别#######不变
i18n("日文"): "all_ja",#全部按日文识别
i18n("中英混合"): "zh",#按中英混合识别####不变
i18n("日英混合"): "ja",#按日英混合识别####不变
i18n("多语种混合"): "auto",#多语种启动切分识别语种
}
dict_language_v2 = {
i18n("中文"): "all_zh",#全部按中文识别
i18n("英文"): "en",#全部按英文识别#######不变
i18n("日文"): "all_ja",#全部按日文识别
i18n("粤语"): "all_yue",#全部按中文识别
i18n("韩文"): "all_ko",#全部按韩文识别
i18n("中英混合"): "zh",#按中英混合识别####不变
i18n("日英混合"): "ja",#按日英混合识别####不变
i18n("粤英混合"): "yue",#按粤英混合识别####不变
i18n("韩英混合"): "ko",#按韩英混合识别####不变
i18n("多语种混合"): "auto",#多语种启动切分识别语种
i18n("多语种混合(粤语)"): "auto_yue",#多语种启动切分识别语种
}
dict_language = dict_language_v1 if version =='v1' else dict_language_v2
def clean_text_inf(text, language, version): def clean_text_inf(text, language, version):
phones, word2ph, norm_text = clean_text(text, language, version) phones, word2ph, norm_text = clean_text(text, language, version)
phones = cleaned_text_to_sequence(phones, version) phones = cleaned_text_to_sequence(phones, version)
@ -609,21 +635,21 @@ def change_choices():
return {"choices": sorted(SoVITS_names, key=custom_sort_key), "__type__": "update"}, {"choices": sorted(GPT_names, key=custom_sort_key), "__type__": "update"} return {"choices": sorted(SoVITS_names, key=custom_sort_key), "__type__": "update"}, {"choices": sorted(GPT_names, key=custom_sort_key), "__type__": "update"}
SoVITS_weight_root="SoVITS_weights_v2" if version=='v2' else "SoVITS_weights" SoVITS_weight_root=["SoVITS_weights_v2","SoVITS_weights"]
GPT_weight_root="GPT_weights_v2" if version=='v2' else "GPT_weights" GPT_weight_root=["GPT_weights_v2","GPT_weights"]
os.makedirs("SoVITS_weights",exist_ok=True) for path in SoVITS_weight_root+GPT_weight_root:
os.makedirs("GPT_weights",exist_ok=True) os.makedirs(path,exist_ok=True)
os.makedirs("SoVITS_weights_v2",exist_ok=True)
os.makedirs("GPT_weights_v2",exist_ok=True)
def get_weights_names(GPT_weight_root, SoVITS_weight_root): def get_weights_names(GPT_weight_root, SoVITS_weight_root):
SoVITS_names = [pretrained_sovits_name] SoVITS_names = [i for i in pretrained_sovits_name]
for name in os.listdir(SoVITS_weight_root): for path in SoVITS_weight_root:
if name.endswith(".pth"): SoVITS_names.append("%s/%s" % (SoVITS_weight_root, name)) for name in os.listdir(path):
GPT_names = [pretrained_gpt_name] if name.endswith(".pth"): SoVITS_names.append("%s/%s" % (path, name))
for name in os.listdir(GPT_weight_root): GPT_names = [i for i in pretrained_gpt_name]
if name.endswith(".ckpt"): GPT_names.append("%s/%s" % (GPT_weight_root, name)) for path in GPT_weight_root:
for name in os.listdir(path):
if name.endswith(".ckpt"): GPT_names.append("%s/%s" % (path, name))
return SoVITS_names, GPT_names return SoVITS_names, GPT_names
@ -639,35 +665,6 @@ def html_left(text, label='p'):
<{label} style="margin: 0; padding: 0;">{text}</{label}> <{label} style="margin: 0; padding: 0;">{text}</{label}>
</div>""" </div>"""
def switch_version(version_, prompt_language, text_language,inp_ref):
os.environ['version']=version_
global pretrained_sovits_name, pretrained_gpt_name, version
version = version_
print(version)
dict_language = dict_language_v1 if version =='v1' else dict_language_v2
if prompt_language in list(dict_language.keys()):
prompt_text_update, prompt_language_update = {'__type__':'update'}, {'__type__':'update', 'value':prompt_language}
else:
prompt_text_update = {'__type__':'update', 'value':''}
prompt_language_update = {'__type__':'update', 'value':i18n("中文")}
if text_language in list(dict_language.keys()):
text_update, text_language_update = {'__type__':'update'}, {'__type__':'update', 'value':text_language}
else:
text_update = {'__type__':'update', 'value':''}
text_language_update = {'__type__':'update', 'value':i18n("中文")}
SoVITS_weight_root="SoVITS_weights_v2" if version=='v2' else "SoVITS_weights"
GPT_weight_root="GPT_weights_v2" if version=='v2' else "GPT_weights"
pretrained_sovits_name="GPT_SoVITS/pretrained_models/s2G488k.pth"if version=="v1"else"GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth"
pretrained_gpt_name="GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt"if version=="v1"else "GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt"
SoVITS_names, GPT_names = get_weights_names(GPT_weight_root, SoVITS_weight_root)
with open(f"./weight.json", 'r', encoding="utf-8") as file:
weight_data = file.read()
weight_data=json.loads(weight_data)
gpt_path = weight_data.get('GPT',{}).get(version,pretrained_gpt_name)
sovits_path = weight_data.get('SoVITS',{}).get(version,pretrained_sovits_name)
print(gpt_path,sovits_path)
return {'__type__':'update', 'value':gpt_path, 'choices':GPT_names}, {'__type__':'update', 'value':sovits_path, 'choices':SoVITS_names}, {'__type__':'update', 'choices':list(dict_language.keys())}, {'__type__':'update', 'choices':list(dict_language.keys())}, prompt_text_update, prompt_language_update, text_update, text_language_update
with gr.Blocks(title="GPT-SoVITS WebUI") as app: with gr.Blocks(title="GPT-SoVITS WebUI") as app:
gr.Markdown( gr.Markdown(
@ -678,11 +675,8 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
with gr.Row(): with gr.Row():
GPT_dropdown = gr.Dropdown(label=i18n("GPT模型列表"), choices=sorted(GPT_names, key=custom_sort_key), value=gpt_path, interactive=True, scale=14) GPT_dropdown = gr.Dropdown(label=i18n("GPT模型列表"), choices=sorted(GPT_names, key=custom_sort_key), value=gpt_path, interactive=True, scale=14)
SoVITS_dropdown = gr.Dropdown(label=i18n("SoVITS模型列表"), choices=sorted(SoVITS_names, key=custom_sort_key), value=sovits_path, interactive=True, scale=14) SoVITS_dropdown = gr.Dropdown(label=i18n("SoVITS模型列表"), choices=sorted(SoVITS_names, key=custom_sort_key), value=sovits_path, interactive=True, scale=14)
refresh_button = gr.Button(i18n("刷新模型路径"), variant="primary", scale=7) refresh_button = gr.Button(i18n("刷新模型路径"), variant="primary", scale=14)
version_dropdown = gr.Dropdown(label=i18n("切换模型版本"), choices=['v1','v2'], value=version, scale=7)
refresh_button.click(fn=change_choices, inputs=[], outputs=[SoVITS_dropdown, GPT_dropdown]) refresh_button.click(fn=change_choices, inputs=[], outputs=[SoVITS_dropdown, GPT_dropdown])
SoVITS_dropdown.change(change_sovits_weights, [SoVITS_dropdown], [])
GPT_dropdown.change(change_gpt_weights, [GPT_dropdown], [])
gr.Markdown(html_center(i18n("*请上传并填写参考信息"),'h3')) gr.Markdown(html_center(i18n("*请上传并填写参考信息"),'h3'))
with gr.Row(): with gr.Row():
inp_ref = gr.Audio(label=i18n("请上传3~10秒内参考音频超过会报错"), type="filepath", scale=13) inp_ref = gr.Audio(label=i18n("请上传3~10秒内参考音频超过会报错"), type="filepath", scale=13)
@ -727,7 +721,8 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
[inp_ref, prompt_text, prompt_language, text, text_language, how_to_cut, top_k, top_p, temperature, ref_text_free,speed,if_freeze], [inp_ref, prompt_text, prompt_language, text, text_language, how_to_cut, top_k, top_p, temperature, ref_text_free,speed,if_freeze],
[output], [output],
) )
version_dropdown.change(switch_version,[version_dropdown,prompt_language,text_language,inp_ref],[GPT_dropdown,SoVITS_dropdown,prompt_language,text_language,prompt_text,prompt_language,text,text_language]) SoVITS_dropdown.change(change_sovits_weights, [SoVITS_dropdown,prompt_language,text_language], [prompt_language,text_language,prompt_text,prompt_language,text,text_language])
GPT_dropdown.change(change_gpt_weights, [GPT_dropdown], [])
# gr.Markdown(value=i18n("文本切分工具。太长的文本合成出来效果不一定好,所以太长建议先切。合成会根据文本的换行分开合成再拼起来。")) # gr.Markdown(value=i18n("文本切分工具。太长的文本合成出来效果不一定好,所以太长建议先切。合成会根据文本的换行分开合成再拼起来。"))
# with gr.Row(): # with gr.Row():

View File

@ -1,6 +1,6 @@
import os,shutil,sys,pdb,re import os,shutil,sys,pdb,re
if len(sys.argv)==1:sys.argv.append('v1') if len(sys.argv)==1:sys.argv.append('v2')
version="v2"if sys.argv[1]=="v2" else"v1" version="v1"if sys.argv[1]=="v1" else"v2"
os.environ["version"]=version os.environ["version"]=version
now_dir = os.getcwd() now_dir = os.getcwd()
sys.path.insert(0, now_dir) sys.path.insert(0, now_dir)
@ -62,8 +62,6 @@ else:
from scipy.io import wavfile from scipy.io import wavfile
from tools.my_utils import load_audio from tools.my_utils import load_audio
from multiprocessing import cpu_count from multiprocessing import cpu_count
from text.g2pw import G2PWPinyin
g2pw = G2PWPinyin(model_dir="GPT_SoVITS/text/G2PWModel",model_source="GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large",v_to_u=False, neutral_tone_with_five=True)
# os.environ['PYTORCH_ENABLE_MPS_FALLBACK'] = '1' # 当遇到mps不支持的步骤时使用cpu # os.environ['PYTORCH_ENABLE_MPS_FALLBACK'] = '1' # 当遇到mps不支持的步骤时使用cpu
n_cpu=cpu_count() n_cpu=cpu_count()
@ -113,23 +111,43 @@ def fix_gpu_numbers(inputs):
return ",".join(output) return ",".join(output)
except: except:
return inputs return inputs
pretrained_sovits_name="GPT_SoVITS/pretrained_models/s2G488k.pth"if version=="v1"else"GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth"
pretrained_gpt_name="GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt"if version=="v1"else "GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt" def get_weights_names(GPT_weight_root, SoVITS_weight_root):
def get_weights_names(): SoVITS_names = [i for i in pretrained_sovits_name]
SoVITS_names = [pretrained_sovits_name] for path in SoVITS_weight_root:
for name in os.listdir(SoVITS_weight_root): for name in os.listdir(path):
if name.endswith(".pth"):SoVITS_names.append(name) if name.endswith(".pth"): SoVITS_names.append("%s/%s" % (path, name))
GPT_names = [pretrained_gpt_name] GPT_names = [i for i in pretrained_gpt_name]
for name in os.listdir(GPT_weight_root): for path in GPT_weight_root:
if name.endswith(".ckpt"): GPT_names.append(name) for name in os.listdir(path):
return SoVITS_names,GPT_names if name.endswith(".ckpt"): GPT_names.append("%s/%s" % (path, name))
SoVITS_weight_root="SoVITS_weights_v2" if version=='v2' else "SoVITS_weights" return SoVITS_names, GPT_names
GPT_weight_root="GPT_weights_v2" if version=='v2' else "GPT_weights"
os.makedirs("SoVITS_weights",exist_ok=True) pretrained_sovits_name=["GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth", "GPT_SoVITS/pretrained_models/s2G488k.pth"]
os.makedirs("GPT_weights",exist_ok=True) pretrained_gpt_name=["GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt", "GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt"]
os.makedirs("SoVITS_weights_v2",exist_ok=True)
os.makedirs("GPT_weights_v2",exist_ok=True) pretrained_model_list = (pretrained_sovits_name[-int(version[-1])+2],pretrained_sovits_name[-int(version[-1])+2].replace("s2G","s2D"),pretrained_gpt_name[-int(version[-1])+2],"GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large","GPT_SoVITS/pretrained_models/chinese-hubert-base")
SoVITS_names,GPT_names = get_weights_names()
_=''
for i in pretrained_model_list:
if os.path.exists(i):...
else:_+=f'\n {i}'
if _:raise FileExistsError(i18n('以下模型不存在:')+_)
_ =[[],[]]
for i in range(2):
if os.path.exists(pretrained_gpt_name[i]):
_[0].append(pretrained_gpt_name[i])
if os.path.exists(pretrained_sovits_name[i]):
_[-1].append(pretrained_sovits_name[i])
pretrained_gpt_name,pretrained_sovits_name = _
SoVITS_weight_root=["SoVITS_weights_v2","SoVITS_weights"]
GPT_weight_root=["GPT_weights_v2","GPT_weights"]
SoVITS_names,GPT_names = get_weights_names(GPT_weight_root, SoVITS_weight_root)
for path in SoVITS_weight_root+GPT_weight_root:
os.makedirs(path,exist_ok=True)
def custom_sort_key(s): def custom_sort_key(s):
# 使用正则表达式提取字符串中的数字部分和非数字部分 # 使用正则表达式提取字符串中的数字部分和非数字部分
@ -300,6 +318,7 @@ def open1Ba(batch_size,total_epoch,exp_name,text_low_lr_rate,if_save_latest,if_s
data["data"]["exp_dir"]=data["s2_ckpt_dir"]=s2_dir data["data"]["exp_dir"]=data["s2_ckpt_dir"]=s2_dir
data["save_weight_dir"]=SoVITS_weight_root data["save_weight_dir"]=SoVITS_weight_root
data["name"]=exp_name data["name"]=exp_name
data["version"]=version
tmp_config_path="%s/tmp_s2.json"%tmp tmp_config_path="%s/tmp_s2.json"%tmp
with open(tmp_config_path,"w")as f:f.write(json.dumps(data)) with open(tmp_config_path,"w")as f:f.write(json.dumps(data))
@ -344,6 +363,7 @@ def open1Bb(batch_size,total_epoch,exp_name,if_dpo,if_save_latest,if_save_every_
data["train_semantic_path"]="%s/6-name2semantic.tsv"%s1_dir data["train_semantic_path"]="%s/6-name2semantic.tsv"%s1_dir
data["train_phoneme_path"]="%s/2-name2text.txt"%s1_dir data["train_phoneme_path"]="%s/2-name2text.txt"%s1_dir
data["output_dir"]="%s/logs_s1"%s1_dir data["output_dir"]="%s/logs_s1"%s1_dir
data["version"]=version
os.environ["_CUDA_VISIBLE_DEVICES"]=fix_gpu_numbers(gpu_numbers.replace("-",",")) os.environ["_CUDA_VISIBLE_DEVICES"]=fix_gpu_numbers(gpu_numbers.replace("-",","))
os.environ["hz"]="25hz" os.environ["hz"]="25hz"
@ -703,6 +723,20 @@ def close1abc():
ps1abc=[] ps1abc=[]
return "已终止所有一键三连进程", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False} return "已终止所有一键三连进程", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False}
def switch_version(version_):
os.environ['version']=version_
global version
version = version_
if len(pretrained_gpt_name) > 1 and len(pretrained_sovits_name) > 1:
return {'__type__':'update', 'value':pretrained_sovits_name[-int(version[-1])+2]}, {'__type__':'update', 'value':pretrained_sovits_name[-int(version[-1])+2].replace("s2G","s2D")}, {'__type__':'update', 'value':pretrained_gpt_name[-int(version[-1])+2]}, {'__type__':'update', 'value':pretrained_gpt_name[-int(version[-1])+2]}, {'__type__':'update', 'value':pretrained_sovits_name[-int(version[-1])+2]}
else:
raise gr.Error(i18n('未下载V1模型'))
from text.g2pw import G2PWPinyin
g2pw = G2PWPinyin(model_dir="GPT_SoVITS/text/G2PWModel",model_source="GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large",v_to_u=False, neutral_tone_with_five=True)
with gr.Blocks(title="GPT-SoVITS WebUI") as app: with gr.Blocks(title="GPT-SoVITS WebUI") as app:
gr.Markdown( gr.Markdown(
value= value=
@ -832,9 +866,10 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
with gr.Row(): with gr.Row():
exp_name = gr.Textbox(label=i18n("*实验/模型名"), value="xxx", interactive=True) exp_name = gr.Textbox(label=i18n("*实验/模型名"), value="xxx", interactive=True)
gpu_info = gr.Textbox(label=i18n("显卡信息"), value=gpu_info, visible=True, interactive=False) gpu_info = gr.Textbox(label=i18n("显卡信息"), value=gpu_info, visible=True, interactive=False)
pretrained_s2G = gr.Textbox(label=i18n("预训练的SoVITS-G模型路径"), value=pretrained_sovits_name, interactive=True) version_checkbox = gr.Radio(label=i18n("版本"),value='v2',choices=['v1','v2'])
pretrained_s2D = gr.Textbox(label=i18n("预训练的SoVITS-D模型路径"), value=pretrained_sovits_name.replace("s2G","s2D"), interactive=True) pretrained_s2G = gr.Textbox(label=i18n("预训练的SoVITS-G模型路径"), value=pretrained_sovits_name[0], interactive=True)
pretrained_s1 = gr.Textbox(label=i18n("预训练的GPT模型路径"), value=pretrained_gpt_name, interactive=True) pretrained_s2D = gr.Textbox(label=i18n("预训练的SoVITS-D模型路径"), value=pretrained_sovits_name[0].replace("s2G","s2D"), interactive=True)
pretrained_s1 = gr.Textbox(label=i18n("预训练的GPT模型路径"), value=pretrained_gpt_name[0], interactive=True)
with gr.TabItem(i18n("1A-训练集格式化工具")): with gr.TabItem(i18n("1A-训练集格式化工具")):
gr.Markdown(value=i18n("输出logs/实验名目录下应有23456开头的文件和文件夹")) gr.Markdown(value=i18n("输出logs/实验名目录下应有23456开头的文件和文件夹"))
with gr.Row(): with gr.Row():
@ -920,8 +955,8 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
with gr.TabItem(i18n("1C-推理")): with gr.TabItem(i18n("1C-推理")):
gr.Markdown(value=i18n("选择训练完存放在SoVITS_weights和GPT_weights下的模型。默认的一个是底模体验5秒Zero Shot TTS用。")) gr.Markdown(value=i18n("选择训练完存放在SoVITS_weights和GPT_weights下的模型。默认的一个是底模体验5秒Zero Shot TTS用。"))
with gr.Row(): with gr.Row():
GPT_dropdown = gr.Dropdown(label=i18n("*GPT模型列表"), choices=sorted(GPT_names,key=custom_sort_key),value=pretrained_gpt_name,interactive=True) GPT_dropdown = gr.Dropdown(label=i18n("*GPT模型列表"), choices=sorted(GPT_names,key=custom_sort_key),value=pretrained_gpt_name[0],interactive=True)
SoVITS_dropdown = gr.Dropdown(label=i18n("*SoVITS模型列表"), choices=sorted(SoVITS_names,key=custom_sort_key),value=pretrained_sovits_name,interactive=True) SoVITS_dropdown = gr.Dropdown(label=i18n("*SoVITS模型列表"), choices=sorted(SoVITS_names,key=custom_sort_key),value=pretrained_sovits_name[0],interactive=True)
gpu_number_1C=gr.Textbox(label=i18n("GPU卡号,只能填1个整数"), value=gpus, interactive=True) gpu_number_1C=gr.Textbox(label=i18n("GPU卡号,只能填1个整数"), value=gpus, interactive=True)
refresh_button = gr.Button(i18n("刷新模型路径"), variant="primary") refresh_button = gr.Button(i18n("刷新模型路径"), variant="primary")
refresh_button.click(fn=change_choices,inputs=[],outputs=[SoVITS_dropdown,GPT_dropdown]) refresh_button.click(fn=change_choices,inputs=[],outputs=[SoVITS_dropdown,GPT_dropdown])
@ -929,6 +964,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
if_tts = gr.Checkbox(label=i18n("是否开启TTS推理WebUI"), show_label=True) if_tts = gr.Checkbox(label=i18n("是否开启TTS推理WebUI"), show_label=True)
tts_info = gr.Textbox(label=i18n("TTS推理WebUI进程输出信息")) tts_info = gr.Textbox(label=i18n("TTS推理WebUI进程输出信息"))
if_tts.change(change_tts_inference, [if_tts,bert_pretrained_dir,cnhubert_base_dir,gpu_number_1C,GPT_dropdown,SoVITS_dropdown], [tts_info]) if_tts.change(change_tts_inference, [if_tts,bert_pretrained_dir,cnhubert_base_dir,gpu_number_1C,GPT_dropdown,SoVITS_dropdown], [tts_info])
version_checkbox.change(switch_version,[version_checkbox],[pretrained_s2G,pretrained_s2D,pretrained_s1,GPT_dropdown,SoVITS_dropdown])
with gr.TabItem(i18n("2-GPT-SoVITS-变声")):gr.Markdown(value=i18n("施工中,请静候佳音")) with gr.TabItem(i18n("2-GPT-SoVITS-变声")):gr.Markdown(value=i18n("施工中,请静候佳音"))
app.queue(concurrency_count=511, max_size=1022).launch( app.queue(concurrency_count=511, max_size=1022).launch(
server_name="0.0.0.0", server_name="0.0.0.0",