Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,9 +7,6 @@ import string
|
|
| 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,7 +33,7 @@ def convert_text_to_speech(parrafo, model):
|
|
| 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,9 +49,11 @@ def convert_text_to_speech(parrafo, model):
|
|
| 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 |
-
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
# Crear la interfaz de Gradio
|
| 58 |
input_text = gr.Textbox(label="Introduce el texto")
|
| 59 |
model_options = [
|
| 60 |
"es_MX-locutor-voice-11400-epoch-high.onnx",
|
|
@@ -64,11 +63,4 @@ model_options = [
|
|
| 64 |
] # Agrega aqu铆 m谩s modelos si es necesario
|
| 65 |
select_model = gr.Dropdown(model_options, label="Selecciona el modelo")
|
| 66 |
|
| 67 |
-
|
| 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)
|
|
|
|
| 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 |
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.exe')
|
| 37 |
|
| 38 |
# Verificar si la ruta es v谩lida
|
| 39 |
if os.path.isfile(piper_exe):
|
|
|
|
| 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 |
+
with open(output_file, 'rb') as audio_file:
|
| 53 |
+
audio_content = audio_file.read()
|
| 54 |
+
return audio_content
|
| 55 |
|
| 56 |
+
# Crear la interfaz de Gradio y especificar el puerto 5000
|
| 57 |
input_text = gr.Textbox(label="Introduce el texto")
|
| 58 |
model_options = [
|
| 59 |
"es_MX-locutor-voice-11400-epoch-high.onnx",
|
|
|
|
| 63 |
] # Agrega aqu铆 m谩s modelos si es necesario
|
| 64 |
select_model = gr.Dropdown(model_options, label="Selecciona el modelo")
|
| 65 |
|
| 66 |
+
gr.Interface(play_audio, inputs=[input_text, select_model], outputs=gr.Audio(), flagging_options=None).launch(share=True, port=5000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|