|
|
|
|
|
|
|
import gradio as gr |
|
import subprocess |
|
import os |
|
import json |
|
import uuid |
|
import requests |
|
from pypipertts import PyPiper |
|
pp=PyPiper() |
|
|
|
def init(): |
|
|
|
key_list=['lb_LU-marylux-medium'] |
|
|
|
return(gr.update(label="Voice",choices=key_list,value="lb_LU-marylux-medium",interactive=True)) |
|
|
|
def load_mod(instr="lb_LU-marylux-medium"): |
|
load_mes=gr.Info(f"""Loading Model...<br>{instr}""",duration=2) |
|
pp.load_mod(instr=instr) |
|
with open(pp.json_ob,'r') as f: |
|
|
|
json_ob=f.read() |
|
load_mes=gr.Info(f"Model Loaded<br>{instr}",duration=2) |
|
return json_ob |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
txt="""PiperTTS is a powerful text-to-speech TTS node designed to convert written text into high-quality spoken audio. This node leverages advanced voice synthesis models to generate natural-sounding speech, making it an invaluable tool for AI developers looking to add a vocal element to their projects.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def button_on(stream): |
|
if stream==True: |
|
return gr.update(interactive=True,visible=True),gr.update(interactive=False,visible=False) |
|
if stream==False: |
|
return gr.update(interactive=False,visible=False),gr.update(interactive=True,visible=True) |
|
def clear_aud(): |
|
return None |
|
with gr.Blocks() as b: |
|
gr.HTML("<h1>Rhasspy Piper LU Streaming</h1>") |
|
with gr.Row(): |
|
with gr.Column(scale=2): |
|
in_txt=gr.Textbox(label="Text",lines=10) |
|
names=gr.Dropdown() |
|
with gr.Row(): |
|
stream_btn=gr.Button("Stream",interactive=True,visible=True) |
|
sub_btn=gr.Button(interactive=False,visible=False) |
|
cancel_btn=gr.Button("Stop") |
|
out_aud=gr.Audio(streaming=True, autoplay=True) |
|
with gr.Column(scale=1): |
|
with gr.Accordion("Control", open=False): |
|
stream=gr.Checkbox(label="Stream",info="Streaming is fast, but lower quality",value=True,interactive=True) |
|
length=gr.Slider(label="Length", minimum=0.01, maximum=10.0, value=1) |
|
noise=gr.Slider(label="Noise", minimum=0.01, maximum=3.0, value=1, visible=True) |
|
|
|
width=gr.Slider(label="Noise Width", minimum=0.01, maximum=3.0, value=1, visible=True) |
|
sen_pause=gr.Slider(label="Sentence Pause", minimum=0.1, maximum=10.0, value=1, visible=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
f1=stream.change(button_on,stream,[stream_btn,sub_btn]) |
|
|
|
|
|
|
|
f5=stream_btn.click(clear_aud,None,out_aud) |
|
f6=stream_btn.click(pp.stream_tts,[in_txt,names,length,noise,width,sen_pause],out_aud) |
|
f7=sub_btn.click(clear_aud,None,out_aud) |
|
f8=sub_btn.click(pp.tts,[in_txt,names,length,noise,width,sen_pause],out_aud) |
|
|
|
cancel_btn.click(None,None,None,cancels=[f1,f5,f6,f7,f8]) |
|
b.load(init,None,names) |
|
|
|
b.queue(default_concurrency_limit=20).launch(max_threads=40) |