File size: 620 Bytes
f391c85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from gtts import gTTS
from gtts.langs import _main_langs
def update(text,lang):
    test = gTTS(text,lang=lang)
    out = f"{text}.mp3"
    test.save(out)
    return out

with gr.Blocks() as demo:
    gr.Markdown("Start typing below and then click **Run** to see the output.")
    with gr.Blocks() as b:
        with gr.Column():
            text = gr.Textbox()
            lang = gr.Dropdown(choices=list(_main_langs().keys()),value="ms")
        with gr.Column():
            output = gr.Audio()
    btn = gr.Button("Run")
    btn.click(fn=update, inputs=[text,lang], outputs=output)

demo.launch()