Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gtts import gTTS
3
+ import os
4
+
5
+ def text_to_speech(text, language):
6
+ tts = gTTS(text=text, lang=language)
7
+ tts.save("output.mp3")
8
+ os.system("mpg321 output.mp3")
9
+
10
+ iface = gr.Interface(
11
+ fn=text_to_speech,
12
+ inputs=["text", "select"],
13
+ outputs="audio",
14
+ title="Text to Speech",
15
+ description="Enter a text and select a language to hear it spoken",
16
+ examples=[["Hello, world!", "en"], ["Bonjour, monde!", "fr"]],
17
+ allow_flagging="never"
18
+ )
19
+
20
+ iface.launch()