MK-316 commited on
Commit
eefc7a9
1 Parent(s): 6a8bfed

Create app.py

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