|
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() |