Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,10 +12,12 @@ def init():
|
|
| 12 |
return(gr.update(label="Voice",choices=key_list,value="en_US-joe-medium",interactive=True))
|
| 13 |
|
| 14 |
def load_mod(instr="en_US-joe-medium"):
|
|
|
|
| 15 |
pp.load_mod(instr=instr)
|
| 16 |
with open(pp.json_ob,'r') as f:
|
| 17 |
#json_ob=json.dumps(f.read(),indent=4)
|
| 18 |
json_ob=f.read()
|
|
|
|
| 19 |
return json_ob
|
| 20 |
|
| 21 |
|
|
@@ -45,7 +47,13 @@ def exp2():
|
|
| 45 |
def exp3():
|
| 46 |
exp_file=f"./example/en_US-ljspeech-high__1__1__0_5__1.json"
|
| 47 |
return(gr.update(value=txt),gr.update(value=exp_file))
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
with gr.Blocks(theme="Hev832/Applio-Theme") as b:
|
| 50 |
gr.HTML("""<h1 style='font-size:xxx-large;font-weight:900;'>Piper Fast TTS</h1>
|
| 51 |
<h4>Piper: <a href='https://github.com/rhasspy/piper' target='_blank'>https://github.com/rhasspy/piper</a></h4>
|
|
@@ -54,7 +62,7 @@ with gr.Blocks(theme="Hev832/Applio-Theme") as b:
|
|
| 54 |
with gr.Row():
|
| 55 |
with gr.Column(scale=1):
|
| 56 |
with gr.Accordion("Control"):
|
| 57 |
-
stream=gr.Checkbox(value=True,interactive=True)
|
| 58 |
length=gr.Slider(label="Length", minimum=0.01, maximum=10.0, value=1)
|
| 59 |
noise=gr.Slider(label="Noise", minimum=0.01, maximum=3.0, value=1)
|
| 60 |
width=gr.Slider(label="Noise Width", minimum=0.01, maximum=3.0, value=1)
|
|
@@ -67,7 +75,9 @@ with gr.Blocks(theme="Hev832/Applio-Theme") as b:
|
|
| 67 |
with gr.Column(scale=2):
|
| 68 |
in_txt=gr.Textbox(label="Text",lines=10)
|
| 69 |
names=gr.Dropdown()
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
out_aud=gr.Audio(streaming=True, autoplay=True)
|
| 72 |
with gr.Column(scale=1):
|
| 73 |
expbtn1=gr.Button("Example 1").click(exp1,None,[in_txt,load_file])
|
|
@@ -75,10 +85,12 @@ with gr.Blocks(theme="Hev832/Applio-Theme") as b:
|
|
| 75 |
expbtn3=gr.Button("Example 3").click(exp3,None,[in_txt,load_file])
|
| 76 |
with gr.Accordion("Model Config"):
|
| 77 |
json_ob=gr.JSON(label="JSON")
|
|
|
|
| 78 |
save_btn.click(save_set,[names,length,noise,width,sen_pause],save_file)
|
| 79 |
load_file.change(load_set,load_file,[names,length,noise,width,sen_pause])
|
| 80 |
-
names.change(load_mod,names,json_ob)
|
| 81 |
-
|
|
|
|
| 82 |
b.load(init,None,names)
|
| 83 |
|
| 84 |
-
b.queue().launch(max_threads=40)
|
|
|
|
| 12 |
return(gr.update(label="Voice",choices=key_list,value="en_US-joe-medium",interactive=True))
|
| 13 |
|
| 14 |
def load_mod(instr="en_US-joe-medium"):
|
| 15 |
+
load_mes=gr.Info(f"Loading Model...\n{instr}",duration=3)
|
| 16 |
pp.load_mod(instr=instr)
|
| 17 |
with open(pp.json_ob,'r') as f:
|
| 18 |
#json_ob=json.dumps(f.read(),indent=4)
|
| 19 |
json_ob=f.read()
|
| 20 |
+
done_mes=gr.Info(f"Model Loaded\n{instr}",duration=3)
|
| 21 |
return json_ob
|
| 22 |
|
| 23 |
|
|
|
|
| 47 |
def exp3():
|
| 48 |
exp_file=f"./example/en_US-ljspeech-high__1__1__0_5__1.json"
|
| 49 |
return(gr.update(value=txt),gr.update(value=exp_file))
|
| 50 |
+
def button_on(stream):
|
| 51 |
+
if stream==True:
|
| 52 |
+
return gr.update(interactive=True,visible=True),gr.update(interactive=False,visible=False)
|
| 53 |
+
if stream==False:
|
| 54 |
+
return gr.update(interactive=False,visible=False),gr.update(interactive=True,visible=True)
|
| 55 |
+
def clear_aud():
|
| 56 |
+
return None
|
| 57 |
with gr.Blocks(theme="Hev832/Applio-Theme") as b:
|
| 58 |
gr.HTML("""<h1 style='font-size:xxx-large;font-weight:900;'>Piper Fast TTS</h1>
|
| 59 |
<h4>Piper: <a href='https://github.com/rhasspy/piper' target='_blank'>https://github.com/rhasspy/piper</a></h4>
|
|
|
|
| 62 |
with gr.Row():
|
| 63 |
with gr.Column(scale=1):
|
| 64 |
with gr.Accordion("Control"):
|
| 65 |
+
stream=gr.Checkbox(label="Stream",info="Streaming is fast, but lower quality",value=True,interactive=True)
|
| 66 |
length=gr.Slider(label="Length", minimum=0.01, maximum=10.0, value=1)
|
| 67 |
noise=gr.Slider(label="Noise", minimum=0.01, maximum=3.0, value=1)
|
| 68 |
width=gr.Slider(label="Noise Width", minimum=0.01, maximum=3.0, value=1)
|
|
|
|
| 75 |
with gr.Column(scale=2):
|
| 76 |
in_txt=gr.Textbox(label="Text",lines=10)
|
| 77 |
names=gr.Dropdown()
|
| 78 |
+
stream_btn=gr.Button("Stream",interactive=True,visible=True)
|
| 79 |
+
sub_btn=gr.Button(interactive=False,visible=False)
|
| 80 |
+
|
| 81 |
out_aud=gr.Audio(streaming=True, autoplay=True)
|
| 82 |
with gr.Column(scale=1):
|
| 83 |
expbtn1=gr.Button("Example 1").click(exp1,None,[in_txt,load_file])
|
|
|
|
| 85 |
expbtn3=gr.Button("Example 3").click(exp3,None,[in_txt,load_file])
|
| 86 |
with gr.Accordion("Model Config"):
|
| 87 |
json_ob=gr.JSON(label="JSON")
|
| 88 |
+
stream.change(button_on,stream,[stream_btn,sub_btn])
|
| 89 |
save_btn.click(save_set,[names,length,noise,width,sen_pause],save_file)
|
| 90 |
load_file.change(load_set,load_file,[names,length,noise,width,sen_pause])
|
| 91 |
+
names.change(load_mod,names,json_ob).then(clear_aud,None,out_aud)
|
| 92 |
+
stream_btn.click(pp.stream_tts,[in_txt,names,length,noise,width,sen_pause],out_aud)
|
| 93 |
+
sub_btn.click(clear_aud,None,out_aud).then(pp.tts,[in_txt,names,length,noise,width,sen_pause],out_aud)
|
| 94 |
b.load(init,None,names)
|
| 95 |
|
| 96 |
+
b.queue(default_concurrency_limit=20).launch(max_threads=40)
|