From 4ce60dc2b2f32f9fe20c3ecb955e000f55b33047 Mon Sep 17 00:00:00 2001 From: limbang <495071565@qq.com> Date: Wed, 12 Apr 2023 23:56:41 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20#140=20shell=3DTrue=20=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84Mac=E3=80=81Linux=E6=8A=A5=E9=94=99=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DMac=E3=80=81Linux=20"shell=3DTrue"=20?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E6=8A=A5=E9=94=99,Win=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E8=BF=99=E4=B8=AA=E4=B9=9F=E4=BC=9A=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webUI.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/webUI.py b/webUI.py index fb81089..33ccc01 100644 --- a/webUI.py +++ b/webUI.py @@ -106,11 +106,11 @@ def tts_func(_text,_rate): elif _rate<0: ratestr="{:.0%}".format(_rate)#减号自带 - p=subprocess.Popen(["edge-tts", - "--text",_text, - "--write-media",output_file, - "--voice",voice, - "--rate="+ratestr] + p=subprocess.Popen("edge-tts "+ + " --text "+_text+ + " --write-media "+output_file+ + " --voice "+voice+ + " --rate="+ratestr ,shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) From 86ae5963644d1219e8c57d6e24a2f7bf1bc3c934 Mon Sep 17 00:00:00 2001 From: limbang <495071565@qq.com> Date: Thu, 13 Apr 2023 00:01:10 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20edge-tts=20?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=97=B6=E7=94=B7=E6=80=A7=E5=A5=B3=E6=80=A7?= =?UTF-8?q?=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webUI.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/webUI.py b/webUI.py index 33ccc01..034d41b 100644 --- a/webUI.py +++ b/webUI.py @@ -93,11 +93,12 @@ def vc_fn(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, noise raise gr.Error(e) -def tts_func(_text,_rate): +def tts_func(_text,_rate,_voice): #使用edge-tts把文字转成音频 # voice = "zh-CN-XiaoyiNeural"#女性,较高音 # voice = "zh-CN-YunxiNeural"#男性 voice = "zh-CN-YunxiNeural"#男性 + if ( _voice == "女" ) : voice = "zh-CN-XiaoyiNeural" output_file = _text[0:10]+".wav" # communicate = edge_tts.Communicate(_text, voice) # await communicate.save(output_file) @@ -114,13 +115,13 @@ def tts_func(_text,_rate): ,shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) - p.wait() + p.wait() return output_file -def vc_fn2(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, noise_scale,pad_seconds,cl_num,lg_num,lgr_num,text2tts,tts_rate,F0_mean_pooling,enhancer_adaptive_key): +def vc_fn2(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, noise_scale,pad_seconds,cl_num,lg_num,lgr_num,text2tts,tts_rate,tts_voice,F0_mean_pooling,enhancer_adaptive_key): #使用edge-tts把文字转成音频 - output_file=tts_func(text2tts,tts_rate) + output_file=tts_func(text2tts,tts_rate,tts_voice) #调整采样率 sr2=44100 @@ -130,7 +131,7 @@ def vc_fn2(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, nois wavfile.write(save_path2,sr2, (wav2 * np.iinfo(np.int16).max).astype(np.int16) ) - + #读取音频 sample_rate, data=gr_pu.audio_from_file(save_path2) vc_input=(sample_rate, data) @@ -172,7 +173,7 @@ with gr.Blocks( sid = gr.Dropdown(label="音色(说话人)") sid_output = gr.Textbox(label="Output Message") - + with gr.Row(variant="panel"): with gr.Column(): gr.Markdown(value=""" @@ -184,7 +185,7 @@ with gr.Blocks( cluster_ratio = gr.Number(label="聚类模型混合比例,0-1之间,0即不启用聚类。使用聚类模型能提升音色相似度,但会导致咬字下降(如果使用建议0.5左右)", value=0) slice_db = gr.Number(label="切片阈值", value=-40) noise_scale = gr.Number(label="noise_scale 建议不要动,会影响音质,玄学参数", value=0.4) - with gr.Column(): + with gr.Column(): pad_seconds = gr.Number(label="推理音频pad秒数,由于未知原因开头结尾会有异响,pad一小段静音段后就不会出现", value=0.5) cl_num = gr.Number(label="音频自动切片,0为不切片,单位为秒(s)", value=0) lg_num = gr.Number(label="两端音频切片的交叉淡入长度,如果自动切片后出现人声不连贯可调整该数值,如果连贯建议采用默认值0,注意,该设置会影响推理速度,单位为秒/s", value=0) @@ -197,6 +198,7 @@ with gr.Blocks( with gr.TabItem("文字转音频"): text2tts=gr.Textbox(label="在此输入要转译的文字。注意,使用该功能建议打开F0预测,不然会很怪") tts_rate = gr.Number(label="tts语速", value=0) + tts_voice = gr.Radio(label="性别",choices=["男","女"], value="男") vc_submit2 = gr.Button("文字转换", variant="primary") with gr.Row(): with gr.Column(): @@ -205,7 +207,7 @@ with gr.Blocks( vc_output2 = gr.Audio(label="Output Audio", interactive=False) vc_submit.click(vc_fn, [sid, vc_input3, vc_transform,auto_f0,cluster_ratio, slice_db, noise_scale,pad_seconds,cl_num,lg_num,lgr_num,F0_mean_pooling,enhancer_adaptive_key], [vc_output1, vc_output2]) - vc_submit2.click(vc_fn2, [sid, vc_input3, vc_transform,auto_f0,cluster_ratio, slice_db, noise_scale,pad_seconds,cl_num,lg_num,lgr_num,text2tts,tts_rate,F0_mean_pooling,enhancer_adaptive_key], [vc_output1, vc_output2]) + vc_submit2.click(vc_fn2, [sid, vc_input3, vc_transform,auto_f0,cluster_ratio, slice_db, noise_scale,pad_seconds,cl_num,lg_num,lgr_num,text2tts,tts_rate,tts_voice,F0_mean_pooling,enhancer_adaptive_key], [vc_output1, vc_output2]) model_load_button.click(modelAnalysis,[model_path,config_path,cluster_model_path,device,enhance],[sid,sid_output]) model_unload_button.click(modelUnload,[],[sid,sid_output]) app.launch() From ce38277539f2f58b74756d721d7176f47fef4106 Mon Sep 17 00:00:00 2001 From: EngsShi Date: Thu, 13 Apr 2023 03:31:53 +0800 Subject: [PATCH 3/4] add webUI.py input text clear fun edge-tts parameters must be pure --- webUI.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webUI.py b/webUI.py index 8fc29f2..14c2736 100644 --- a/webUI.py +++ b/webUI.py @@ -124,9 +124,12 @@ def tts_func(_text,_rate,_voice): p.wait() return output_file +def text_clear(text): + return re.sub(r"[\n\,\(\) ]", "", text) def vc_fn2(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, noise_scale,pad_seconds,cl_num,lg_num,lgr_num,text2tts,tts_rate,tts_voice,F0_mean_pooling,enhancer_adaptive_key): #使用edge-tts把文字转成音频 + text2tts=text_clear(text2tts) output_file=tts_func(text2tts,tts_rate,tts_voice) #调整采样率 From 4b27899f5383709b4200a838eb13b74a1b5975fd Mon Sep 17 00:00:00 2001 From: EngsShi Date: Thu, 13 Apr 2023 03:34:33 +0800 Subject: [PATCH 4/4] remove double btn --- webUI.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/webUI.py b/webUI.py index 14c2736..af2aa72 100644 --- a/webUI.py +++ b/webUI.py @@ -224,9 +224,8 @@ with gr.Blocks( """) debug_button = gr.Checkbox(label="Debug模式,如果向社区反馈BUG需要打开,打开后控制台可以显示具体错误提示", value=debug) vc_submit.click(vc_fn, [sid, vc_input3, vc_transform,auto_f0,cluster_ratio, slice_db, noise_scale,pad_seconds,cl_num,lg_num,lgr_num,F0_mean_pooling,enhancer_adaptive_key], [vc_output1, vc_output2]) - vc_submit2.click(vc_fn2, [sid, vc_input3, vc_transform,auto_f0,cluster_ratio, slice_db, noise_scale,pad_seconds,cl_num,lg_num,lgr_num,text2tts,tts_rate,F0_mean_pooling,enhancer_adaptive_key], [vc_output1, vc_output2]) - debug_button.change(debug_change,[],[]) vc_submit2.click(vc_fn2, [sid, vc_input3, vc_transform,auto_f0,cluster_ratio, slice_db, noise_scale,pad_seconds,cl_num,lg_num,lgr_num,text2tts,tts_rate,tts_voice,F0_mean_pooling,enhancer_adaptive_key], [vc_output1, vc_output2]) + debug_button.change(debug_change,[],[]) model_load_button.click(modelAnalysis,[model_path,config_path,cluster_model_path,device,enhance],[sid,sid_output]) model_unload_button.click(modelUnload,[],[sid,sid_output]) app.launch()