Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline | |
| from TTS.api import TTS | |
| # Configurar gerador de texto | |
| gerador_texto = pipeline("text-generation", model="unicamp-dl/ptt5-base-portuguese-vocab") | |
| # Configurar TTS (Texto para Fala) | |
| tts = TTS(model_name="tts_models/pt-cv/vits") | |
| # Função para gerar texto e áudio | |
| def gerar_texto_fala(prompt): | |
| # Gera texto | |
| texto = gerador_texto(prompt, max_length=100)[0]["generated_text"] | |
| # Gera fala | |
| audio_path = "fala.mp3" | |
| tts.tts_to_file(text=texto, file_path=audio_path) | |
| return texto, audio_path | |
| # Interface do Gradio | |
| interface = gr.Interface( | |
| fn=gerar_texto_fala, | |
| inputs=gr.Textbox(label="Escreva um prompt (ex: Fale sobre IA):"), | |
| outputs=[gr.Textbox(label="Texto Gerado"), gr.Audio(label="Áudio Gerado")], | |
| title="Geração de Texto e Fala em Português" | |
| ) | |
| interface.launch() | |