Compare commits

...

3 Commits

Author SHA1 Message Date
Songhuadanjiang
88f006fa55
Merge b2d725ed9a2d50465f7882ecdd06715d66ef66bd into d6b78c927acf89dfc12acb1bc561c1c963543ecf 2025-06-09 12:09:02 +08:00
wzy3650
d6b78c927a
fix configs error (#2439)
* fix configs error

* fix configs error

---------

Co-authored-by: wangzeyuan <wangzeyuan@agora.io>
Co-authored-by: wangzeyuan <wangzeyuan@shengwang.cn>
2025-06-09 11:25:55 +08:00
Songhuadanjiang
b2d725ed9a
2025-6-1 14:13 2025-06-01 14:13:10 +08:00
4 changed files with 18 additions and 10 deletions

View File

@ -214,7 +214,7 @@ v3v4set = {"v3", "v4"}
def change_sovits_weights(sovits_path, prompt_language=None, text_language=None):
if "" in sovits_path:
if "" in sovits_path or "!" in sovits_path:
sovits_path = name2sovits_path[sovits_path]
global vq_model, hps, version, model_version, dict_language, if_lora_v3
version, model_version, if_lora_v3 = get_sovits_version_from_path_fast(sovits_path)
@ -361,7 +361,7 @@ except:
def change_gpt_weights(gpt_path):
if "" in gpt_path:
if "" in gpt_path or "!" in gpt_path:
gpt_path = name2gpt_path[gpt_path]
global hz, max_sec, t2s_model, config
hz = 50

View File

@ -114,11 +114,11 @@ tts_config.device = device
tts_config.is_half = is_half
tts_config.version = version
if gpt_path is not None:
if "" in gpt_path:
if "" in gpt_path or "!" in gpt_path:
gpt_path = name2gpt_path[gpt_path]
tts_config.t2s_weights_path = gpt_path
if sovits_path is not None:
if "" in sovits_path:
if "" in sovits_path or "!" in sovits_path:
sovits_path = name2sovits_path[sovits_path]
tts_config.vits_weights_path = sovits_path
if cnhubert_base_path is not None:
@ -217,7 +217,7 @@ v3v4set = {"v3", "v4"}
def change_sovits_weights(sovits_path, prompt_language=None, text_language=None):
if "" in sovits_path:
if "" in sovits_path or "!" in sovits_path:
sovits_path = name2sovits_path[sovits_path]
global version, model_version, dict_language, if_lora_v3
version, model_version, if_lora_v3 = get_sovits_version_from_path_fast(sovits_path)
@ -283,6 +283,12 @@ def change_sovits_weights(sovits_path, prompt_language=None, text_language=None)
f.write(json.dumps(data))
def change_gpt_weights(gpt_path):
if "" in gpt_path or "!" in gpt_path:
gpt_path = name2gpt_path[gpt_path]
tts_pipeline.init_t2s_weights(gpt_path)
with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False, js=js, css=css) as app:
gr.HTML(
top_html.format(
@ -457,7 +463,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False, js=js, css=css
inference_button,
],
) #
GPT_dropdown.change(tts_pipeline.init_t2s_weights, [GPT_dropdown], [])
GPT_dropdown.change(change_gpt_weights, [GPT_dropdown], [])
with gr.Group():
gr.Markdown(

View File

@ -127,7 +127,7 @@ def get_sovits_version_from_path_fast(sovits_path):
def load_sovits_new(sovits_path):
f = open(sovits_path, "rb")
meta = f.read(2)
if meta != "PK":
if meta != b"PK":
data = b"PK" + f.read()
bio = BytesIO()
bio.write(data)

8
api.py
View File

@ -313,9 +313,11 @@ def get_sovits_weights(sovits_path):
if model_version == "v3":
hps.model.version = "v3"
if model_version == "v4":
hps.model.version = "v4"
model_params_dict = vars(hps.model)
if model_version != "v3":
if model_version != "v3" and model_version != "v4":
vq_model = SynthesizerTrn(
hps.data.filter_length // 2 + 1,
hps.train.segment_size // hps.data.hop_length,
@ -759,7 +761,7 @@ def get_tts_wav(
prompt_semantic = codes[0, 0]
prompt = prompt_semantic.unsqueeze(0).to(device)
if version != "v3":
if version != "v3" and version != "v4":
refers = []
if inp_refs:
for path in inp_refs:
@ -811,7 +813,7 @@ def get_tts_wav(
pred_semantic = pred_semantic[:, -idx:].unsqueeze(0)
t3 = ttime()
if version != "v3":
if version != "v3" and version != "v4":
audio = (
vq_model.decode(pred_semantic, torch.LongTensor(phones2).to(device).unsqueeze(0), refers, speed=speed)
.detach()