text-to-speech / app.py
vishal2002's picture
Update app.py
e1b4aaf verified
raw
history blame
316 Bytes
import gradio as gr
from gtts import gTTS
import tempfile
import os
def text_to_speech(text):
tts = gTTS(text=text, lang='en')
_, temp_path = tempfile.mkstemp(suffix=".mp3")
tts.save(temp_path)
return temp_path
iface = gr.Interface(fn=text_to_speech, inputs="text", outputs="audio")
iface.launch()