EKEnglish commited on
Commit
c4cd89f
1 Parent(s): 3da4c17

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Install the necessary libraries
2
+ # !pip install gtts gradio
3
+
4
+ from gtts import gTTS
5
+ import gradio as gr
6
+
7
+ # Function to convert text to audio
8
+ def text_to_audio(mytext):
9
+ # Create a gTTS object
10
+ tts = gTTS(text=mytext, lang='en')
11
+ # Save the audio file
12
+ filename = "output.mp3"
13
+ tts.save(filename)
14
+ return filename
15
+
16
+ # Gradio interface
17
+ def gradio_interface(text):
18
+ audio_file = text_to_audio(text)
19
+ return audio_file
20
+
21
+ # Create a Gradio interface
22
+ iface = gr.Interface(
23
+ fn=gradio_interface,
24
+ inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
25
+ outputs=gr.Audio(type="filepath"),
26
+ title="Text to Speech Application (English audio)",
27
+ description="Type your text and to generate the corresponding audio in English."
28
+ )
29
+
30
+ # Launch the interface
31
+ iface.launch(share=True)