@ -195,7 +195,7 @@ def change_tts_inference(if_tts,bert_path,cnhubert_base_path,gpu_number,gpt_path
yield i18n ( " TTS推理进程已关闭 " )
from tools . asr . config import asr_dict
def open_asr ( asr_inp_dir , asr_opt_dir , asr_model , asr_model_size , asr_lang ):
def open_asr ( asr_inp_dir , asr_opt_dir , asr_model , asr_model_size , asr_lang , asr_precision ):
global p_asr
if ( p_asr == None ) :
asr_inp_dir = my_utils . clean_path ( asr_inp_dir )
@ -205,16 +205,18 @@ def open_asr(asr_inp_dir, asr_opt_dir, asr_model, asr_model_size, asr_lang):
cmd + = f ' -o " { asr_opt_dir } " '
cmd + = f ' -s { asr_model_size } '
cmd + = f ' -l { asr_lang } '
cmd + = " -p %s " % ( " float16 " if is_half == True else " float32 " )
yield " ASR任务开启: %s " % cmd , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
cmd + = f " -p { asr_precision } "
output_file_name = os . path . basename ( asr_inp_dir )
output_folder = asr_opt_dir or " output/asr_opt "
output_file_path = os . path . abspath ( f ' { output_folder } / { output_file_name } .list ' )
yield " ASR任务开启: %s " % cmd , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " }
print ( cmd )
p_asr = Popen ( cmd , shell = True )
p_asr . wait ( )
p_asr = None
yield f " ASR任务完成, 查看终端进行下一步 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
yield f " ASR任务完成, 查看终端进行下一步 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " value " : output_file_path }
else :
yield " 已有正在进行的ASR任务, 需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
yield " 已有正在进行的ASR任务, 需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " }
# return None
def close_asr ( ) :
@ -222,7 +224,7 @@ def close_asr():
if ( p_asr != None ) :
kill_process ( p_asr . pid )
p_asr = None
return " 已终止ASR进程 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
return " 已终止ASR进程 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
def open_denoise ( denoise_inp_dir , denoise_opt_dir ) :
global p_denoise
if ( p_denoise == None ) :
@ -230,14 +232,14 @@ def open_denoise(denoise_inp_dir, denoise_opt_dir):
denoise_opt_dir = my_utils . clean_path ( denoise_opt_dir )
cmd = ' " %s " tools/cmd-denoise.py -i " %s " -o " %s " -p %s ' % ( python_exec , denoise_inp_dir , denoise_opt_dir , " float16 " if is_half == True else " float32 " )
yield " 语音降噪任务开启: %s " % cmd , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
yield " 语音降噪任务开启: %s " % cmd , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " }
print ( cmd )
p_denoise = Popen ( cmd , shell = True )
p_denoise . wait ( )
p_denoise = None
yield f " 语音降噪任务完成, 查看终端进行下一步 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
yield f " 语音降噪任务完成, 查看终端进行下一步 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " value " : denoise_opt_dir }
else :
yield " 已有正在进行的语音降噪任务,需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
yield " 已有正在进行的语音降噪任务,需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " }
# return None
def close_denoise ( ) :
@ -245,7 +247,7 @@ def close_denoise():
if ( p_denoise != None ) :
kill_process ( p_denoise . pid )
p_denoise = None
return " 已终止语音降噪进程 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
return " 已终止语音降噪进程 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
p_train_SoVITS = None
def open1Ba ( batch_size , total_epoch , exp_name , text_low_lr_rate , if_save_latest , if_save_every_weights , save_every_epoch , gpu_numbers1Ba , pretrained_s2G , pretrained_s2D ) :
@ -275,21 +277,21 @@ def open1Ba(batch_size,total_epoch,exp_name,text_low_lr_rate,if_save_latest,if_s
with open ( tmp_config_path , " w " ) as f : f . write ( json . dumps ( data ) )
cmd = ' " %s " GPT_SoVITS/s2_train.py --config " %s " ' % ( python_exec , tmp_config_path )
yield " SoVITS训练开始: %s " % cmd , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
yield " SoVITS训练开始: %s " % cmd , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
print ( cmd )
p_train_SoVITS = Popen ( cmd , shell = True )
p_train_SoVITS . wait ( )
p_train_SoVITS = None
yield " SoVITS训练完成 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
yield " SoVITS训练完成 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
else :
yield " 已有正在进行的SoVITS训练任务, 需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
yield " 已有正在进行的SoVITS训练任务, 需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
def close1Ba ( ) :
global p_train_SoVITS
if ( p_train_SoVITS != None ) :
kill_process ( p_train_SoVITS . pid )
p_train_SoVITS = None
return " 已终止SoVITS训练 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
return " 已终止SoVITS训练 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
p_train_GPT = None
def open1Bb ( batch_size , total_epoch , exp_name , if_dpo , if_save_latest , if_save_every_weights , save_every_epoch , gpu_numbers , pretrained_s1 ) :
@ -322,21 +324,21 @@ def open1Bb(batch_size,total_epoch,exp_name,if_dpo,if_save_latest,if_save_every_
with open ( tmp_config_path , " w " ) as f : f . write ( yaml . dump ( data , default_flow_style = False ) )
# cmd = '"%s" GPT_SoVITS/s1_train.py --config_file "%s" --train_semantic_path "%s/6-name2semantic.tsv" --train_phoneme_path "%s/2-name2text.txt" --output_dir "%s/logs_s1"'%(python_exec,tmp_config_path,s1_dir,s1_dir,s1_dir)
cmd = ' " %s " GPT_SoVITS/s1_train.py --config_file " %s " ' % ( python_exec , tmp_config_path )
yield " GPT训练开始: %s " % cmd , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
yield " GPT训练开始: %s " % cmd , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
print ( cmd )
p_train_GPT = Popen ( cmd , shell = True )
p_train_GPT . wait ( )
p_train_GPT = None
yield " GPT训练完成 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
yield " GPT训练完成 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
else :
yield " 已有正在进行的GPT训练任务, 需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
yield " 已有正在进行的GPT训练任务, 需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
def close1Bb ( ) :
global p_train_GPT
if ( p_train_GPT != None ) :
kill_process ( p_train_GPT . pid )
p_train_GPT = None
return " 已终止GPT训练 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
return " 已终止GPT训练 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
ps_slice = [ ]
def open_slice ( inp , opt_root , threshold , min_length , min_interval , hop_size , max_sil_kept , _max , alpha , n_parts ) :
@ -344,12 +346,12 @@ def open_slice(inp,opt_root,threshold,min_length,min_interval,hop_size,max_sil_k
inp = my_utils . clean_path ( inp )
opt_root = my_utils . clean_path ( opt_root )
if ( os . path . exists ( inp ) == False ) :
yield " 输入路径不存在 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
yield " 输入路径不存在 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " } , { " __type__ " : " update " }
return
if os . path . isfile ( inp ) : n_parts = 1
elif os . path . isdir ( inp ) : pass
else :
yield " 输入路径存在但既不是文件也不是文件夹 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
yield " 输入路径存在但既不是文件也不是文件夹 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " } , { " __type__ " : " update " }
return
if ( ps_slice == [ ] ) :
for i_part in range ( n_parts ) :
@ -357,13 +359,13 @@ def open_slice(inp,opt_root,threshold,min_length,min_interval,hop_size,max_sil_k
print ( cmd )
p = Popen ( cmd , shell = True )
ps_slice . append ( p )
yield " 切割执行中 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
yield " 切割执行中 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " } , { " __type__ " : " update " }
for p in ps_slice :
p . wait ( )
ps_slice = [ ]
yield " 切割结束 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
yield " 切割结束 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " value " : opt_root } , { " __type__ " : " update " , " value " : opt_root }
else :
yield " 已有正在进行的切割任务,需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
yield " 已有正在进行的切割任务,需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " } , { " __type__ " : " update " }
def close_slice ( ) :
global ps_slice
@ -470,7 +472,7 @@ def open1b(inp_text,inp_wav_dir,exp_name,gpu_numbers,ssl_pretrained_dir):
for p in ps1b :
p . wait ( )
ps1b = [ ]
yield " SSL提取进程结束 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
yield " SSL提取进程结束 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
else :
yield " 已有正在进行的SSL提取任务, 需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
@ -527,7 +529,7 @@ def open1c(inp_text,exp_name,gpu_numbers,pretrained_s2G_path):
with open ( path_semantic , " w " , encoding = " utf8 " ) as f :
f . write ( " \n " . join ( opt ) + " \n " )
ps1c = [ ]
yield " 语义token提取进程结束 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
yield " 语义token提取进程结束 " , { " __type__ " : " update " , " visible " : True } , { " __type__ " : " update " , " visible " : False }
else :
yield " 已有正在进行的语义token提取任务, 需先终止才能开启下一次任务 " , { " __type__ " : " update " , " visible " : False } , { " __type__ " : " update " , " visible " : True }
@ -692,33 +694,37 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
uvr5_info = gr . Textbox ( label = i18n ( " UVR5进程输出信息 " ) )
gr . Markdown ( value = i18n ( " 0b-语音切分工具 " ) )
with gr . Row ( ) :
with gr . Row ( ) :
slice_inp_path = gr . Textbox ( label = i18n ( " 音频自动切分输入路径,可文件可文件夹 " ) , value = " " )
slice_opt_root = gr . Textbox ( label = i18n ( " 切分后的子音频的输出根目录 " ) , value = " output/slicer_opt " )
threshold = gr . Textbox ( label = i18n ( " threshold:音量小于这个值视作静音的备选切割点 " ) , value = " -34 " )
min_length = gr . Textbox ( label = i18n ( " min_length:每段最小多长,如果第一段太短一直和后面段连起来直到超过这个值 " ) , value = " 4000 " )
min_interval = gr . Textbox ( label = i18n ( " min_interval:最短切割间隔 " ) , value = " 300 " )
hop_size = gr . Textbox ( label = i18n ( " hop_size:怎么算音量曲线,越小精度越大计算量越高(不是精度越大效果越好) " ) , value = " 10 " )
max_sil_kept = gr . Textbox ( label = i18n ( " max_sil_kept:切完后静音最多留多长 " ) , value = " 500 " )
with gr . Row ( ) :
open_slicer_button = gr . Button ( i18n ( " 开启语音切割 " ) , variant = " primary " , visible = True )
close_slicer_button = gr . Button ( i18n ( " 终止语音切割 " ) , variant = " primary " , visible = False )
_max = gr . Slider ( minimum = 0 , maximum = 1 , step = 0.05 , label = i18n ( " max:归一化后最大值多少 " ) , value = 0.9 , interactive = True )
alpha = gr . Slider ( minimum = 0 , maximum = 1 , step = 0.05 , label = i18n ( " alpha_mix:混多少比例归一化后音频进来 " ) , value = 0.25 , interactive = True )
n_process = gr . Slider ( minimum = 1 , maximum = n_cpu , step = 1 , label = i18n ( " 切割使用的进程数 " ) , value = 4 , interactive = True )
slicer_info = gr . Textbox ( label = i18n ( " 语音切割进程输出信息 " ) )
with gr . Column ( scale = 3 ) :
with gr . Row ( ) :
slice_inp_path = gr . Textbox ( label = i18n ( " 音频自动切分输入路径,可文件可文件夹 " ) , value = " " )
slice_opt_root = gr . Textbox ( label = i18n ( " 切分后的子音频的输出根目录 " ) , value = " output/slicer_opt " )
with gr . Row ( ) :
threshold = gr . Textbox ( label = i18n ( " threshold:音量小于这个值视作静音的备选切割点 " ) , value = " -34 " )
min_length = gr . Textbox ( label = i18n ( " min_length:每段最小多长,如果第一段太短一直和后面段连起来直到超过这个值 " ) , value = " 4000 " )
min_interval = gr . Textbox ( label = i18n ( " min_interval:最短切割间隔 " ) , value = " 300 " )
hop_size = gr . Textbox ( label = i18n ( " hop_size:怎么算音量曲线,越小精度越大计算量越高(不是精度越大效果越好) " ) , value = " 10 " )
max_sil_kept = gr . Textbox ( label = i18n ( " max_sil_kept:切完后静音最多留多长 " ) , value = " 500 " )
with gr . Row ( ) :
_max = gr . Slider ( minimum = 0 , maximum = 1 , step = 0.05 , label = i18n ( " max:归一化后最大值多少 " ) , value = 0.9 , interactive = True )
alpha = gr . Slider ( minimum = 0 , maximum = 1 , step = 0.05 , label = i18n ( " alpha_mix:混多少比例归一化后音频进来 " ) , value = 0.25 , interactive = True )
n_process = gr . Slider ( minimum = 1 , maximum = n_cpu , step = 1 , label = i18n ( " 切割使用的进程数 " ) , value = 4 , interactive = True )
with gr . Row ( ) :
slicer_info = gr . Textbox ( label = i18n ( " 语音切割进程输出信息 " ) )
open_slicer_button = gr . Button ( i18n ( " 开启语音切割 " ) , variant = " primary " , visible = True )
close_slicer_button = gr . Button ( i18n ( " 终止语音切割 " ) , variant = " primary " , visible = False )
gr . Markdown ( value = i18n ( " 0bb-语音降噪工具 " ) )
with gr . Row ( ) :
with gr . Column ( scale = 3 ) :
with gr . Row ( ) :
denoise_input_dir = gr . Textbox ( label = i18n ( " 降噪音频文件输入文件夹 " ) , value = " " )
denoise_output_dir = gr . Textbox ( label = i18n ( " 降噪结果输出文件夹 " ) , value = " output/denoise_opt " )
with gr . Row ( ) :
denoise_info = gr . Textbox ( label = i18n ( " 语音降噪进程输出信息 " ) )
open_denoise_button = gr . Button ( i18n ( " 开启语音降噪 " ) , variant = " primary " , visible = True )
close_denoise_button = gr . Button ( i18n ( " 终止语音降噪进程 " ) , variant = " primary " , visible = False )
denoise_input_dir = gr . Textbox ( label = i18n ( " 降噪音频文件输入文件夹 " ) , value = " " )
denoise_output_dir = gr . Textbox ( label = i18n ( " 降噪结果输出文件夹 " ) , value = " output/denoise_opt " )
denoise_info = gr . Textbox ( label = i18n ( " 语音降噪进程输出信息 " ) )
gr . Markdown ( value = i18n ( " 0c-中文批量离线ASR工具 " ) )
with gr . Row ( ) :
open_asr_button = gr . Button ( i18n ( " 开启离线批量ASR " ) , variant = " primary " , visible = True )
close_asr_button = gr . Button ( i18n ( " 终止ASR进程 " ) , variant = " primary " , visible = False )
with gr . Column ( ) :
with gr . Column ( scale = 3 ) :
with gr . Row ( ) :
asr_inp_dir = gr . Textbox (
label = i18n ( " 输入文件夹路径 " ) ,
@ -749,17 +755,39 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
interactive = True ,
value = " zh "
)
asr_precision = gr . Dropdown (
label = i18n ( " ASR 精度设置 " ) ,
choices = [ " float32 " ] ,
interactive = True ,
value = " float32 "
)
with gr . Row ( ) :
asr_info = gr . Textbox ( label = i18n ( " ASR进程输出信息 " ) )
asr_info = gr . Textbox ( label = i18n ( " ASR进程输出信息 " ) )
open_asr_button = gr . Button ( i18n ( " 开启离线批量ASR " ) , variant = " primary " , visible = True )
close_asr_button = gr . Button ( i18n ( " 终止ASR进程 " ) , variant = " primary " , visible = False )
def change_lang_choices ( key ) : #根据选择的模型修改可选的语言
# return gr.Dropdown(choices=asr_dict[key]['lang'])
return { " __type__ " : " update " , " choices " : asr_dict [ key ] [ ' lang ' ] , " value " : asr_dict [ key ] [ ' lang ' ] [ 0 ] }
def change_size_choices ( key ) : # 根据选择的模型修改可选的模型尺寸
# return gr.Dropdown(choices=asr_dict[key]['size'])
return { " __type__ " : " update " , " choices " : asr_dict [ key ] [ ' size ' ] }
return { " __type__ " : " update " , " choices " : asr_dict [ key ] [ ' size ' ] , " value " : asr_dict [ key ] [ ' size ' ] [ - 1 ] }
def change_precision_choices ( key ) : #根据选择的模型修改可选的语言
if key == " Faster Whisper (多语种) " :
if default_batch_size < = 4 :
precision = ' int8 '
elif is_half :
precision = ' float16 '
else :
precision = ' float32 '
else :
precision = ' float32 '
# return gr.Dropdown(choices=asr_dict[key]['precision'])
return { " __type__ " : " update " , " choices " : asr_dict [ key ] [ ' precision ' ] , " value " : precision }
asr_model . change ( change_lang_choices , [ asr_model ] , [ asr_lang ] )
asr_model . change ( change_size_choices , [ asr_model ] , [ asr_size ] )
asr_model . change ( change_precision_choices , [ asr_model ] , [ asr_precision ] )
gr . Markdown ( value = i18n ( " 0d-语音文本校对标注工具 " ) )
with gr . Row ( ) :
@ -772,11 +800,11 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
label_info = gr . Textbox ( label = i18n ( " 打标工具进程输出信息 " ) )
if_label . change ( change_label , [ if_label , path_list ] , [ label_info ] )
if_uvr5 . change ( change_uvr5 , [ if_uvr5 ] , [ uvr5_info ] )
open_asr_button . click ( open_asr , [ asr_inp_dir , asr_opt_dir , asr_model , asr_size , asr_lang ], [ asr_info , open_asr_button , close_asr_button ] )
open_asr_button . click ( open_asr , [ asr_inp_dir , asr_opt_dir , asr_model , asr_size , asr_lang , asr_precision ], [ asr_info , open_asr_button , close_asr_button , path_list ] )
close_asr_button . click ( close_asr , [ ] , [ asr_info , open_asr_button , close_asr_button ] )
open_slicer_button . click ( open_slice , [ slice_inp_path , slice_opt_root , threshold , min_length , min_interval , hop_size , max_sil_kept , _max , alpha , n_process ] , [ slicer_info , open_slicer_button , close_slicer_button ])
open_slicer_button . click ( open_slice , [ slice_inp_path , slice_opt_root , threshold , min_length , min_interval , hop_size , max_sil_kept , _max , alpha , n_process ] , [ slicer_info , open_slicer_button , close_slicer_button ,asr_inp_dir , denoise_input_dir ])
close_slicer_button . click ( close_slice , [ ] , [ slicer_info , open_slicer_button , close_slicer_button ] )
open_denoise_button . click ( open_denoise , [ denoise_input_dir , denoise_output_dir ] , [ denoise_info , open_denoise_button , close_denoise_button ])
open_denoise_button . click ( open_denoise , [ denoise_input_dir , denoise_output_dir ] , [ denoise_info , open_denoise_button , close_denoise_button ,asr_inp_dir ])
close_denoise_button . click ( close_denoise , [ ] , [ denoise_info , open_denoise_button , close_denoise_button ] )
with gr . TabItem ( i18n ( " 1-GPT-SoVITS-TTS " ) ) :
@ -879,4 +907,4 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
share = is_share ,
server_port = webui_port_main ,
quiet = True ,
)
)