Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,13 +38,16 @@ def generate(prompt,history,max_new_tokens,seed):
|
|
| 38 |
buf = ""
|
| 39 |
for response in stream:
|
| 40 |
output += response.token.text
|
| 41 |
-
#buf += response.token.text
|
| 42 |
-
#if response.token.text == "\n" or response.token.text == "</s>" or response.token.text == ". ":
|
| 43 |
yield [(prompt,output)], output
|
| 44 |
|
| 45 |
def tts(inp,voice,length,noise,width,sen_pause):
|
|
|
|
| 46 |
yield from pp.stream_tts(inp,voice,length,noise,width,sen_pause)
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
with gr.Blocks() as iface:
|
| 49 |
stt=gr.State()
|
| 50 |
gr.HTML("""""")
|
|
@@ -52,10 +55,11 @@ with gr.Blocks() as iface:
|
|
| 52 |
#chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
|
| 53 |
chatbot=gr.Chatbot()
|
| 54 |
msg = gr.Textbox()
|
| 55 |
-
with gr.
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
| 59 |
with gr.Accordion("Voice Controls",open=False):
|
| 60 |
names=gr.Dropdown(label="Voice", choices=pp.key_list,value="en_US-joe-medium")
|
| 61 |
length=gr.Slider(label="Length", minimum=0.01, maximum=10.0, value=1)
|
|
@@ -64,7 +68,7 @@ with gr.Blocks() as iface:
|
|
| 64 |
sen_pause=gr.Slider(label="Sentence Pause", minimum=0.1, maximum=10.0, value=1)
|
| 65 |
upd_btn=gr.Button("Update")
|
| 66 |
|
| 67 |
-
names.change(
|
| 68 |
sub_b = submit_b.click(generate, [msg,chatbot],[chatbot,stt]).then(tts,[stt,names,length,noise,width,sen_pause],aud)
|
| 69 |
sub_e = msg.submit(generate, [msg, chatbot], aud)
|
| 70 |
stop_b.click(None,None,None, cancels=[sub_b,sub_e])
|
|
|
|
| 38 |
buf = ""
|
| 39 |
for response in stream:
|
| 40 |
output += response.token.text
|
|
|
|
|
|
|
| 41 |
yield [(prompt,output)], output
|
| 42 |
|
| 43 |
def tts(inp,voice,length,noise,width,sen_pause):
|
| 44 |
+
inp=inp.strip("</s>")
|
| 45 |
yield from pp.stream_tts(inp,voice,length,noise,width,sen_pause)
|
| 46 |
+
def load_mod(model):
|
| 47 |
+
yield f"Loading: {model}"
|
| 48 |
+
pp.load_mod(model)
|
| 49 |
+
yield f"Voice Loaded: {model}"
|
| 50 |
+
|
| 51 |
with gr.Blocks() as iface:
|
| 52 |
stt=gr.State()
|
| 53 |
gr.HTML("""""")
|
|
|
|
| 55 |
#chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
|
| 56 |
chatbot=gr.Chatbot()
|
| 57 |
msg = gr.Textbox()
|
| 58 |
+
with gr.Group():
|
| 59 |
+
with gr.Row():
|
| 60 |
+
submit_b = gr.Button()
|
| 61 |
+
stop_b = gr.Button("Stop")
|
| 62 |
+
clear = gr.ClearButton([msg, chatbot])
|
| 63 |
with gr.Accordion("Voice Controls",open=False):
|
| 64 |
names=gr.Dropdown(label="Voice", choices=pp.key_list,value="en_US-joe-medium")
|
| 65 |
length=gr.Slider(label="Length", minimum=0.01, maximum=10.0, value=1)
|
|
|
|
| 68 |
sen_pause=gr.Slider(label="Sentence Pause", minimum=0.1, maximum=10.0, value=1)
|
| 69 |
upd_btn=gr.Button("Update")
|
| 70 |
|
| 71 |
+
names.change(load_mod,names,msg)
|
| 72 |
sub_b = submit_b.click(generate, [msg,chatbot],[chatbot,stt]).then(tts,[stt,names,length,noise,width,sen_pause],aud)
|
| 73 |
sub_e = msg.submit(generate, [msg, chatbot], aud)
|
| 74 |
stop_b.click(None,None,None, cancels=[sub_b,sub_e])
|