mytts / app.py
MK-316's picture
Create app.py
eefc7a9 verified
raw
history blame
692 Bytes
# Paste our code here
# 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"),
)
# Launch the interface
iface.launch(share=True)