Merge pull request #147 from limbang/4.0
fix: #140,添加 edge-tts 生成时男性女性选择
This commit is contained in:
commit
efff8edfef
19
webUI.py
19
webUI.py
|
@ -99,11 +99,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)
|
||||
|
@ -112,11 +113,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)
|
||||
|
@ -124,9 +125,9 @@ def tts_func(_text,_rate):
|
|||
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
|
||||
|
@ -206,6 +207,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():
|
||||
|
@ -221,6 +223,7 @@ with gr.Blocks(
|
|||
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])
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue