mytts / app.py
englissi's picture
Create app.py
41851c9 verified
raw
history blame contribute delete
No virus
810 Bytes
# 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)