TestTTS / app.py
MAKHLWF's picture
Update app.py
4b1b73d
raw
history blame
542 Bytes
import gradio as gr
import gtts
import io
def text_to_speech(text):
# Use gTTS to convert text to speech and save it as an MP3 file
speech = gtts.gTTS(text)
mp3_data = io.BytesIO()
speech.save(mp3_data)
mp3_data.seek(0)
return mp3_data.read()
iface = gr.Interface(
fn=text_to_speech,
inputs="text",
outputs=gr.Audio(type="numpy", label="Voice"),
title="Text to Speech",
description="Enter text and click 'Generate' to convert it to speech.",
theme="compact",
live=True,
)
iface.launch()