Spaces:
Running
Running
File size: 562 Bytes
c2f4591 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from gtts import gTTS
import gradio as gr
import tempfile
import os
def speak(text):
# Generate audio from text using Google TTS
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as fp:
tts = gTTS(text)
tts.save(fp.name)
return fp.name
gr.Interface(
fn=speak,
inputs=gr.Textbox(label="Enter text to speak"),
outputs=gr.Audio(type="filepath", label="Spoken Output"),
title="Text-to-Speech Agent 🎙️",
description="Type text and hear AI speak it aloud!",
allow_flagging="never",
).launch()
|