weyavon578 commited on
Commit
2cdb3c8
·
verified ·
1 Parent(s): 5414f50

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ from TTS.api import TTS
4
+
5
+ # Configurar gerador de texto
6
+ gerador_texto = pipeline("text-generation", model="unicamp-dl/ptt5-base-portuguese-vocab")
7
+
8
+ # Configurar TTS (Texto para Fala)
9
+ tts = TTS(model_name="tts_models/pt-cv/vits")
10
+
11
+ # Função para gerar texto e áudio
12
+ def gerar_texto_fala(prompt):
13
+ # Gera texto
14
+ texto = gerador_texto(prompt, max_length=100)[0]["generated_text"]
15
+
16
+ # Gera fala
17
+ audio_path = "fala.mp3"
18
+ tts.tts_to_file(text=texto, file_path=audio_path)
19
+
20
+ return texto, audio_path
21
+
22
+ # Interface do Gradio
23
+ interface = gr.Interface(
24
+ fn=gerar_texto_fala,
25
+ inputs=gr.Textbox(label="Escreva um prompt (ex: Fale sobre IA):"),
26
+ outputs=[gr.Textbox(label="Texto Gerado"), gr.Audio(label="Áudio Gerado")],
27
+ title="Geração de Texto e Fala em Português"
28
+ )
29
+
30
+ interface.launch()