mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-11 11:19:58 +08:00
* changes * changes * revert changes * changes * add changeset * notebooks script * changes * changes --------- Co-authored-by: Ali Abid <aliabid94@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
20 lines
617 B
Python
20 lines
617 B
Python
import tempfile
|
|
import gradio as gr
|
|
from neon_tts_plugin_coqui import CoquiTTS
|
|
|
|
LANGUAGES = list(CoquiTTS.langs.keys())
|
|
coquiTTS = CoquiTTS()
|
|
|
|
def tts(text: str, language: str):
|
|
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
|
coquiTTS.get_tts(text, fp, speaker = {"language" : language})
|
|
return fp.name
|
|
|
|
inputs = [gr.Textbox(label="Input", value=CoquiTTS.langs["en"]["sentence"], max_lines=3),
|
|
gr.Radio(label="Language", choices=LANGUAGES, value="en")]
|
|
outputs = gr.Audio(label="Output")
|
|
|
|
demo = gr.Interface(fn=tts, inputs=inputs, outputs=outputs)
|
|
|
|
demo.launch()
|