33import sys
44now_dir = os .getcwd ()
55sys .path .append (now_dir )
6- import traceback
6+ import traceback , pdb
77import warnings
88
99import numpy as np
@@ -396,7 +396,7 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format
396396
397397
398398# 一个选项卡全局只能有一个音色
399- def get_vc (sid ):
399+ def get_vc (sid , to_return_protect0 , to_return_protect1 ):
400400 global n_spk , tgt_sr , net_g , vc , cpt , version
401401 if sid == "" or sid == []:
402402 global hubert_model
@@ -434,6 +434,11 @@ def get_vc(sid):
434434 tgt_sr = cpt ["config" ][- 1 ]
435435 cpt ["config" ][- 3 ] = cpt ["weight" ]["emb_g.weight" ].shape [0 ] # n_spk
436436 if_f0 = cpt .get ("f0" , 1 )
437+ if (if_f0 == 0 ):
438+ to_return_protect0 = to_return_protect1 = {"visible" : False , "value" : 0.5 , "__type__" : "update" }
439+ else :
440+ to_return_protect0 = {"visible" : True , "value" : to_return_protect0 , "__type__" : "update" }
441+ to_return_protect1 = {"visible" : True , "value" : to_return_protect1 , "__type__" : "update" }
437442 version = cpt .get ("version" , "v1" )
438443 if version == "v1" :
439444 if if_f0 == 1 :
@@ -454,7 +459,7 @@ def get_vc(sid):
454459 net_g = net_g .float ()
455460 vc = VC (tgt_sr , config )
456461 n_spk = cpt ["config" ][- 3 ]
457- return {"visible" : True , "maximum" : n_spk , "__type__" : "update" }
462+ return {"visible" : True , "maximum" : n_spk , "__type__" : "update" }, to_return_protect0 , to_return_protect1
458463
459464
460465def change_choices ():
@@ -1247,11 +1252,6 @@ def export_onnx(ModelPath, ExportedPath):
12471252 interactive = True ,
12481253 )
12491254 clean_button .click (fn = clean , inputs = [], outputs = [sid0 ])
1250- sid0 .change (
1251- fn = get_vc ,
1252- inputs = [sid0 ],
1253- outputs = [spk_item ],
1254- )
12551255 with gr .Group ():
12561256 gr .Markdown (
12571257 value = i18n ("男转女推荐+12key, 女转男推荐-12key, 如果音域爆炸导致音色失真也可以自己调整到合适音域. " )
@@ -1475,6 +1475,11 @@ def export_onnx(ModelPath, ExportedPath):
14751475 ],
14761476 [vc_output3 ],
14771477 )
1478+ sid0 .change (
1479+ fn = get_vc ,
1480+ inputs = [sid0 ,protect0 ,protect1 ],
1481+ outputs = [spk_item ,protect0 ,protect1 ],
1482+ )
14781483 with gr .TabItem (i18n ("伴奏人声分离&去混响&去回声" )):
14791484 with gr .Group ():
14801485 gr .Markdown (
0 commit comments