File size: 810 Bytes
e0587d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Install the necessary libraries
# !pip install gtts gradio

from gtts import gTTS
import gradio as gr

# Function to convert text to audio
def text_to_audio(mytext):
    # Create a gTTS object
    tts = gTTS(text=mytext, lang='en')
    # Save the audio file
    filename = "output.mp3"
    tts.save(filename)
    return filename

# Gradio interface
def gradio_interface(text):
    audio_file = text_to_audio(text)
    return audio_file

# Create a Gradio interface
iface = gr.Interface(
    fn=gradio_interface,
    inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
    outputs=gr.Audio(type="filepath"),
    title="Text to Speech Application (English audio)",
    description="Type your text and to generate the corresponding audio in English."
)

# Launch the interface
iface.launch(share=True)