import tempfile import gradio as gr from neon_tts_plugin_coqui import CoquiTTS LANGUAGES = [ "en", "pl", "uk", ] title = "πŸΈπŸ’¬ - NeonAI Coqui AI TTS Plugin" description = "πŸΈπŸ’¬ - a deep learning toolkit for Text-to-Speech, battle-tested in research and production" info = "more info at [Neon Coqui TTS Plugin](https://github.com/NeonGeckoCom/neon-tts-plugin-coqui), [Coqui TTS](https://github.com/coqui-ai/TTS)" coquiTTS = CoquiTTS() def tts(text: str, language: str): print(text, language) # return output with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp: coquiTTS.get_tts(text, fp, speaker = {"language" : language}) return fp.name with gr.Blocks() as blocks: gr.Markdown("

" + title + "

") gr.Markdown(description) with gr.Row():# equal_height=False with gr.Column():# variant="panel" textbox = gr.Textbox( label="Input", value="Hello, how are you?", max_lines=3, ) radio = gr.Radio( label="Language", choices=LANGUAGES, ) with gr.Row():# mobile_collapse=False submit = gr.Button("Submit", variant="primary") audio = gr.Audio(label="Output", interactive=False) gr.Markdown(info) # actions submit.click( tts, [textbox, radio], [audio], ) blocks.launch()