import gradio as gr import subprocess import os import json import uuid import requests from pypipertts import PyPiper pp=PyPiper() length=1 noise=1 width=1 sen_pause=1 stream=True def load_mod(instr="lb_LU-marylux-medium"): load_mes=gr.Info(f"""Loading Model...
{instr}""",duration=2) pp.load_mod(instr=instr) with open(pp.json_ob,'r') as f: #json_ob=json.dumps(f.read(),indent=4) json_ob=f.read() load_mes=gr.Info(f"Model Loaded
{instr}",duration=2) return json_ob def save_set(model,length,noise,width,sen_pause): if not os.path.isdir(f'{os.getcwd()}/saved'): os.mkdir(f'{os.getcwd()}/saved') set_json={"model":model,"length":length,"noise":noise,"width":width,"pause":sen_pause} file_name=f'{model}__{length}__{noise}__{width}__{sen_pause}'.replace(".","_") with open(f'{os.getcwd()}/saved/{file_name}.json','w') as file: file.write(json.dumps(set_json,indent=4)) file.close() return(f'{os.getcwd()}/saved/{file_name}.json') def load_set(set_file): with open(set_file,'r') as file: set_json=json.loads(file.read()) file.close() return(gr.update(value=set_json['model']),gr.update(value=set_json['length']), gr.update(value=set_json['noise']),gr.update(value=set_json['width']), gr.update(value=set_json['pause'])) 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("""

Piper Fast TTS

Piper: https://github.com/rhasspy/piper

PyPiperTTS: https://github.com/broadfield-dev/PyPiperTTS

""") 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) b.queue(default_concurrency_limit=20).launch(max_threads=40)