1010 增加无索引支持
1111 f0算法改harvest(怎么看就只有这个会影响CPU占用),但是不这么改效果不好
1212"""
13- import os , sys , traceback
13+ import os , sys , traceback , re
1414
1515import json
1616
@@ -448,27 +448,43 @@ def event_handler(self):
448448 self .flag_vc = False
449449 exit ()
450450 if event == "start_vc" and self .flag_vc == False :
451- self .set_values (values )
452- print ("using_cuda:" + str (torch .cuda .is_available ()))
453- self .start_vc ()
454- settings = {
455- "pth_path" : values ["pth_path" ],
456- "index_path" : values ["index_path" ],
457- "sg_input_device" : values ["sg_input_device" ],
458- "sg_output_device" : values ["sg_output_device" ],
459- "threhold" : values ["threhold" ],
460- "pitch" : values ["pitch" ],
461- "index_rate" : values ["index_rate" ],
462- "block_time" : values ["block_time" ],
463- "crossfade_length" : values ["crossfade_length" ],
464- "extra_time" : values ["extra_time" ],
465- }
466- with open ("values1.json" , "w" ) as j :
467- json .dump (settings , j )
451+ if self .set_values (values ) == True :
452+ print ("using_cuda:" + str (torch .cuda .is_available ()))
453+ self .start_vc ()
454+ settings = {
455+ "pth_path" : values ["pth_path" ],
456+ "index_path" : values ["index_path" ],
457+ "sg_input_device" : values ["sg_input_device" ],
458+ "sg_output_device" : values ["sg_output_device" ],
459+ "threhold" : values ["threhold" ],
460+ "pitch" : values ["pitch" ],
461+ "index_rate" : values ["index_rate" ],
462+ "block_time" : values ["block_time" ],
463+ "crossfade_length" : values ["crossfade_length" ],
464+ "extra_time" : values ["extra_time" ],
465+ }
466+ with open ("values1.json" , "w" ) as j :
467+ json .dump (settings , j )
468468 if event == "stop_vc" and self .flag_vc == True :
469469 self .flag_vc = False
470470
471471 def set_values (self , values ):
472+ if (len (values ["pth_path" ].strip ()) == 0 ):
473+ sg .popup (i18n ('请选择pth文件' ))
474+ return False
475+ if (len (values ["index_path" ].strip ()) == 0 ):
476+ sg .popup (i18n ('请选择index文件' ))
477+ return False
478+ pattern = re .compile ("[^\x00 -\x7F ]+" )
479+ if (pattern .findall (values ["hubert_path" ])):
480+ sg .popup (i18n ('hubert模型路径不可包含中文' ))
481+ return False
482+ if (pattern .findall (values ["pth_path" ])):
483+ sg .popup (i18n ('pth文件路径不可包含中文' ))
484+ return False
485+ if (pattern .findall (values ["index_path" ])):
486+ sg .popup (i18n ('index文件路径不可包含中文' ))
487+ return False
472488 self .set_devices (values ["sg_input_device" ], values ["sg_output_device" ])
473489 self .config .hubert_path = os .path .join (current_dir , "hubert_base.pt" )
474490 self .config .pth_path = values ["pth_path" ]
@@ -482,6 +498,7 @@ def set_values(self, values):
482498 self .config .I_noise_reduce = values ["I_noise_reduce" ]
483499 self .config .O_noise_reduce = values ["O_noise_reduce" ]
484500 self .config .index_rate = values ["index_rate" ]
501+ return True
485502
486503 def start_vc (self ):
487504 torch .cuda .empty_cache ()
0 commit comments