@@ -119,7 +119,6 @@ def load_hubert():
119119 uvr5_names .append (name .replace (".pth" , "" ))
120120
121121
122-
123122def vc_single (
124123 sid ,
125124 input_audio ,
@@ -888,23 +887,27 @@ def change_info_(ckpt_path):
888887
889888from infer_pack .models_onnx_moess import SynthesizerTrnMs256NSFsidM
890889from infer_pack .models_onnx import SynthesizerTrnMs256NSFsidO
890+
891+
891892def export_onnx (ModelPath , ExportedPath , MoeVS = True ):
892- hidden_channels = 256 # hidden_channels,为768Vec做准备
893- cpt = torch .load (ModelPath , map_location = "cpu" )
894- cpt ["config" ][- 3 ] = cpt ["weight" ]["emb_g.weight" ].shape [0 ] # n_spk
893+ hidden_channels = 256 # hidden_channels,为768Vec做准备
894+ cpt = torch .load (ModelPath , map_location = "cpu" )
895+ cpt ["config" ][- 3 ] = cpt ["weight" ]["emb_g.weight" ].shape [0 ] # n_spk
895896 print (* cpt ["config" ])
896897
897- test_phone = torch .rand (1 , 200 , hidden_channels ) # hidden unit
898- test_phone_lengths = torch .tensor ([200 ]).long () # hidden unit 长度(貌似没啥用)
899- test_pitch = torch .randint (size = (1 , 200 ), low = 5 , high = 255 ) # 基频(单位赫兹)
900- test_pitchf = torch .rand (1 , 200 ) # nsf基频
901- test_ds = torch .LongTensor ([0 ]) # 说话人ID
902- test_rnd = torch .rand (1 , 192 , 200 ) # 噪声(加入随机因子)
898+ test_phone = torch .rand (1 , 200 , hidden_channels ) # hidden unit
899+ test_phone_lengths = torch .tensor ([200 ]).long () # hidden unit 长度(貌似没啥用)
900+ test_pitch = torch .randint (size = (1 , 200 ), low = 5 , high = 255 ) # 基频(单位赫兹)
901+ test_pitchf = torch .rand (1 , 200 ) # nsf基频
902+ test_ds = torch .LongTensor ([0 ]) # 说话人ID
903+ test_rnd = torch .rand (1 , 192 , 200 ) # 噪声(加入随机因子)
903904
904- device = "cpu" #导出时设备(不影响使用模型)
905+ device = "cpu" # 导出时设备(不影响使用模型)
905906
906907 if MoeVS :
907- net_g = SynthesizerTrnMs256NSFsidM (* cpt ["config" ], is_half = False ) # fp32导出(C++要支持fp16必须手动将内存重新排列所以暂时不用fp16)
908+ net_g = SynthesizerTrnMs256NSFsidM (
909+ * cpt ["config" ], is_half = False
910+ ) # fp32导出(C++要支持fp16必须手动将内存重新排列所以暂时不用fp16)
908911 net_g .load_state_dict (cpt ["weight" ], strict = False )
909912 input_names = ["phone" , "phone_lengths" , "pitch" , "pitchf" , "ds" , "rnd" ]
910913 output_names = [
@@ -934,7 +937,9 @@ def export_onnx(ModelPath, ExportedPath, MoeVS=True):
934937 output_names = output_names ,
935938 )
936939 else :
937- net_g = SynthesizerTrnMs256NSFsidO (* cpt ["config" ], is_half = False ) # fp32导出(C++要支持fp16必须手动将内存重新排列所以暂时不用fp16)
940+ net_g = SynthesizerTrnMs256NSFsidO (
941+ * cpt ["config" ], is_half = False
942+ ) # fp32导出(C++要支持fp16必须手动将内存重新排列所以暂时不用fp16)
938943 net_g .load_state_dict (cpt ["weight" ], strict = False )
939944 input_names = ["phone" , "phone_lengths" , "pitch" , "pitchf" , "ds" ]
940945 output_names = [
@@ -963,6 +968,7 @@ def export_onnx(ModelPath, ExportedPath, MoeVS=True):
963968 )
964969 return "Finished"
965970
971+
966972with gr .Blocks () as app :
967973 gr .Markdown (
968974 value = i18n (
@@ -1443,7 +1449,9 @@ def export_onnx(ModelPath, ExportedPath, MoeVS=True):
14431449 with gr .Row ():
14441450 ckpt_dir = gr .Textbox (label = i18n ("RVC模型路径" ), value = "" , interactive = True )
14451451 with gr .Row ():
1446- onnx_dir = gr .Textbox (label = i18n ("Onnx输出路径" ), value = "" , interactive = True )
1452+ onnx_dir = gr .Textbox (
1453+ label = i18n ("Onnx输出路径" ), value = "" , interactive = True
1454+ )
14471455 with gr .Row ():
14481456 moevs = gr .Checkbox (label = i18n ("MoeVS模型" ), value = True )
14491457 infoOnnx = gr .Label (label = "Null" )
0 commit comments