Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from gtts import gTTS | |
| import os | |
| def text_to_speech(text, language='pt'): | |
| # Generate speech | |
| tts = gTTS(text=text, lang=language) | |
| # Save temporary file | |
| audio_path = "output.mp3" | |
| tts.save(audio_path) | |
| return audio_path | |
| def process_text(text, language): | |
| if not text.strip(): | |
| return None | |
| return text_to_speech(text, language) | |
| # Interface Gradio | |
| iface = gr.Interface( | |
| fn=process_text, | |
| inputs=[ | |
| gr.Textbox(label="Digite o texto", lines=5), | |
| gr.Dropdown(choices=["pt", "en", "es", "fr"], value="pt", label="Idioma") | |
| ], | |
| outputs=gr.Audio(label="Áudio gerado", type="filepath"), | |
| title="Conversor de Texto para Voz", | |
| description="Digite um texto e converta para áudio MP3", | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() |