Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,9 @@ import string
|
|
| 7 |
import gradio as gr
|
| 8 |
import tempfile
|
| 9 |
import re
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def filter_text(text):
|
| 12 |
# Expresi贸n regular para permitir solo letras de la A a la Z en may煤sculas y min煤sculas,
|
|
@@ -33,7 +36,7 @@ def convert_text_to_speech(parrafo, model):
|
|
| 33 |
output_file = os.path.join('.', random_name)
|
| 34 |
|
| 35 |
# Construir la ruta al archivo piper.exe
|
| 36 |
-
piper_exe = os.path.join(bundle_dir, 'piper
|
| 37 |
|
| 38 |
# Verificar si la ruta es v谩lida
|
| 39 |
if os.path.isfile(piper_exe):
|
|
@@ -49,9 +52,7 @@ def convert_text_to_speech(parrafo, model):
|
|
| 49 |
# Funci贸n para cargar y reproducir el archivo de audio en Gradio
|
| 50 |
def play_audio(parrafo, model):
|
| 51 |
output_file = convert_text_to_speech(parrafo, model)
|
| 52 |
-
|
| 53 |
-
audio_content = audio_file.read()
|
| 54 |
-
return audio_content
|
| 55 |
|
| 56 |
# Crear la interfaz de Gradio
|
| 57 |
input_text = gr.Textbox(label="Introduce el texto")
|
|
@@ -63,4 +64,11 @@ model_options = [
|
|
| 63 |
] # Agrega aqu铆 m谩s modelos si es necesario
|
| 64 |
select_model = gr.Dropdown(model_options, label="Selecciona el modelo")
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
import tempfile
|
| 9 |
import re
|
| 10 |
+
from flask import Flask, send_file
|
| 11 |
+
|
| 12 |
+
app = Flask(__name__)
|
| 13 |
|
| 14 |
def filter_text(text):
|
| 15 |
# Expresi贸n regular para permitir solo letras de la A a la Z en may煤sculas y min煤sculas,
|
|
|
|
| 36 |
output_file = os.path.join('.', random_name)
|
| 37 |
|
| 38 |
# Construir la ruta al archivo piper.exe
|
| 39 |
+
piper_exe = os.path.join(bundle_dir, 'piper')
|
| 40 |
|
| 41 |
# Verificar si la ruta es v谩lida
|
| 42 |
if os.path.isfile(piper_exe):
|
|
|
|
| 52 |
# Funci贸n para cargar y reproducir el archivo de audio en Gradio
|
| 53 |
def play_audio(parrafo, model):
|
| 54 |
output_file = convert_text_to_speech(parrafo, model)
|
| 55 |
+
return send_file(output_file, mimetype="audio/wav", as_attachment=True)
|
|
|
|
|
|
|
| 56 |
|
| 57 |
# Crear la interfaz de Gradio
|
| 58 |
input_text = gr.Textbox(label="Introduce el texto")
|
|
|
|
| 64 |
] # Agrega aqu铆 m谩s modelos si es necesario
|
| 65 |
select_model = gr.Dropdown(model_options, label="Selecciona el modelo")
|
| 66 |
|
| 67 |
+
# Definir la ruta para Gradio
|
| 68 |
+
@app.route("/")
|
| 69 |
+
def home():
|
| 70 |
+
return gr.Interface(play_audio, inputs=[input_text, select_model], outputs=gr.Audio(), flagging_options=None).launch()
|
| 71 |
+
|
| 72 |
+
# Ejecutar la aplicaci贸n en el puerto 5000
|
| 73 |
+
if __name__ == "__main__":
|
| 74 |
+
app.run(port=5000)
|