import gradio as gr import subprocess import os import json import uuid import requests from pypipertts import PyPiper pp=PyPiper() def init(): key_list=pp.key_list return(gr.update(label="Voice",choices=key_list,value="en_US-joe-medium",interactive=True)) def load_mod(instr="en_US-joe-medium"): 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() 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 exp1(): exp_file=f"./example/en_US-libritts-high__1_4__0_3__0_2__1.json" return(gr.update(value=txt),gr.update(value=exp_file)) def exp2(): exp_file=f"./example/en_US-ryan-high__1__0_6__0_01__1.json" return(gr.update(value=txt),gr.update(value=exp_file)) def exp3(): exp_file=f"./example/en_US-ljspeech-high__1__1__0_5__1.json" return(gr.update(value=txt),gr.update(value=exp_file)) def stream_check(checked,in_txt,names,length,noise,width,sen_pause): if checked: yield pp.stream_tts(in_txt,names,length,noise,width,sen_pause).getvalue() else: return pp.tts(in_txt,names,length,noise,width,sen_pause).getvalue() with gr.Blocks(theme="Hev832/Applio-Theme") as b: gr.HTML("""