Skip to content

Commit 144073a

Browse files
FlynnD273fumiama
andauthored
Automatically select index file when model is selected (#894)
* automatically select index file when model is selected * Search for full directory of index file * Add trailing separator char to index search string * disable debug log * remove unused re --------- Co-authored-by: 源文雨 <[email protected]>
1 parent 0784b4e commit 144073a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

infer-web.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,16 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format
399399
torch.cuda.empty_cache()
400400
yield "\n".join(infos)
401401

402+
def get_index_path_from_model(sid):
403+
sel_index_path = ""
404+
name = os.path.join("logs", sid.split(".")[0], "")
405+
# print(name)
406+
for f in index_paths:
407+
if name in f:
408+
# print("selected index path:", f)
409+
sel_index_path = f
410+
break
411+
return sel_index_path
402412

403413
# 一个选项卡全局只能有一个音色
404414
def get_vc(sid, to_return_protect0, to_return_protect1):
@@ -434,6 +444,7 @@ def get_vc(sid, to_return_protect0, to_return_protect1):
434444
return {"visible": False, "__type__": "update"}
435445
person = "%s/%s" % (weight_root, sid)
436446
print("loading %s" % person)
447+
437448
cpt = torch.load(person, map_location="cpu")
438449
tgt_sr = cpt["config"][-1]
439450
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
@@ -479,6 +490,7 @@ def get_vc(sid, to_return_protect0, to_return_protect1):
479490
{"visible": True, "maximum": n_spk, "__type__": "update"},
480491
to_return_protect0,
481492
to_return_protect1,
493+
get_index_path_from_model(sid),
482494
)
483495

484496

@@ -1629,7 +1641,7 @@ def export_onnx(ModelPath, ExportedPath):
16291641
sid0.change(
16301642
fn=get_vc,
16311643
inputs=[sid0, protect0, protect1],
1632-
outputs=[spk_item, protect0, protect1],
1644+
outputs=[spk_item, protect0, protect1, file_index2],
16331645
)
16341646
with gr.TabItem(i18n("伴奏人声分离&去混响&去回声")):
16351647
with gr.Group():

0 commit comments

Comments
 (0)