Spaces:
Runtime error
Runtime error
Commit
•
a58890f
1
Parent(s):
85a20a5
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Suponiendo que usas un modelo de TTS entrenado que está disponible en Hugging Face
|
5 |
+
# Reemplaza esto con el nombre de tu modelo
|
6 |
+
tts_model_name = "jildardo"
|
7 |
+
|
8 |
+
# Cargar el modelo TTS
|
9 |
+
tts = pipeline("text-to-speech", model=tts_model_name)
|
10 |
+
|
11 |
+
# Función para convertir texto a voz
|
12 |
+
def text_to_speech(text):
|
13 |
+
audio = tts(text)
|
14 |
+
return audio["wav"]
|
15 |
+
|
16 |
+
# Función para reproducir audio
|
17 |
+
def play_audio(audio_file):
|
18 |
+
return audio_file
|
19 |
+
|
20 |
+
# Configuración de la interfaz Gradio
|
21 |
+
iface = gr.Interface(
|
22 |
+
fn=[text_to_speech, play_audio],
|
23 |
+
inputs=[gr.Textbox(lines=2, placeholder="Introduce el texto aquí..."), gr.Audio(source="upload", type="file")],
|
24 |
+
outputs=[gr.Audio(type="file"), gr.Audio(type="file")],
|
25 |
+
layout="vertical"
|
26 |
+
)
|
27 |
+
|
28 |
+
# Lanzar la aplicación
|
29 |
+
iface.launch()
|