10
10
增加无索引支持
11
11
f0算法改harvest(怎么看就只有这个会影响CPU占用),但是不这么改效果不好
12
12
"""
13
- import os , sys , traceback
13
+ import os , sys , traceback , re
14
14
15
15
import json
16
16
@@ -448,27 +448,43 @@ def event_handler(self):
448
448
self .flag_vc = False
449
449
exit ()
450
450
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 )
468
468
if event == "stop_vc" and self .flag_vc == True :
469
469
self .flag_vc = False
470
470
471
471
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
472
488
self .set_devices (values ["sg_input_device" ], values ["sg_output_device" ])
473
489
self .config .hubert_path = os .path .join (current_dir , "hubert_base.pt" )
474
490
self .config .pth_path = values ["pth_path" ]
@@ -482,6 +498,7 @@ def set_values(self, values):
482
498
self .config .I_noise_reduce = values ["I_noise_reduce" ]
483
499
self .config .O_noise_reduce = values ["O_noise_reduce" ]
484
500
self .config .index_rate = values ["index_rate" ]
501
+ return True
485
502
486
503
def start_vc (self ):
487
504
torch .cuda .empty_cache ()
0 commit comments