3
3
import sys
4
4
now_dir = os .getcwd ()
5
5
sys .path .append (now_dir )
6
- import traceback
6
+ import traceback , pdb
7
7
import warnings
8
8
9
9
import numpy as np
@@ -396,7 +396,7 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format
396
396
397
397
398
398
# 一个选项卡全局只能有一个音色
399
- def get_vc (sid ):
399
+ def get_vc (sid , to_return_protect0 , to_return_protect1 ):
400
400
global n_spk , tgt_sr , net_g , vc , cpt , version
401
401
if sid == "" or sid == []:
402
402
global hubert_model
@@ -434,6 +434,11 @@ def get_vc(sid):
434
434
tgt_sr = cpt ["config" ][- 1 ]
435
435
cpt ["config" ][- 3 ] = cpt ["weight" ]["emb_g.weight" ].shape [0 ] # n_spk
436
436
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" }
437
442
version = cpt .get ("version" , "v1" )
438
443
if version == "v1" :
439
444
if if_f0 == 1 :
@@ -454,7 +459,7 @@ def get_vc(sid):
454
459
net_g = net_g .float ()
455
460
vc = VC (tgt_sr , config )
456
461
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
458
463
459
464
460
465
def change_choices ():
@@ -1247,11 +1252,6 @@ def export_onnx(ModelPath, ExportedPath):
1247
1252
interactive = True ,
1248
1253
)
1249
1254
clean_button .click (fn = clean , inputs = [], outputs = [sid0 ])
1250
- sid0 .change (
1251
- fn = get_vc ,
1252
- inputs = [sid0 ],
1253
- outputs = [spk_item ],
1254
- )
1255
1255
with gr .Group ():
1256
1256
gr .Markdown (
1257
1257
value = i18n ("男转女推荐+12key, 女转男推荐-12key, 如果音域爆炸导致音色失真也可以自己调整到合适音域. " )
@@ -1475,6 +1475,11 @@ def export_onnx(ModelPath, ExportedPath):
1475
1475
],
1476
1476
[vc_output3 ],
1477
1477
)
1478
+ sid0 .change (
1479
+ fn = get_vc ,
1480
+ inputs = [sid0 ,protect0 ,protect1 ],
1481
+ outputs = [spk_item ,protect0 ,protect1 ],
1482
+ )
1478
1483
with gr .TabItem (i18n ("伴奏人声分离&去混响&去回声" )):
1479
1484
with gr .Group ():
1480
1485
gr .Markdown (
0 commit comments