Spaces:
Runtime error
Runtime error
| import os | |
| import gradio as gr | |
| def saludo(nombre: str) -> str: | |
| return f"Hola {nombre}!" | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| nombre = gr.Textbox(label="Tu nombre") | |
| salida = gr.Textbox(label="Respuesta") | |
| boton = gr.Button("Saludar") | |
| boton.click(fn=saludo, inputs=nombre, outputs=salida) | |
| # Hugging Face Spaces espera que la aplicación esté en el puerto 7860, accesible desde 0.0.0.0 | |
| # Se establece un valor fijo para evitar problemas de configuración | |
| if __name__ == "__main__": | |
| demo.launch(server_name="0.0.0.0", server_port=7860, show_api=True) | |
| #import os | |
| #import gradio as gr | |
| #from TTS.api import TTS | |
| #MODEL_PATH = "./best_model.pth" | |
| #def tts_infer(text): | |
| # if not os.path.exists(MODEL_PATH): | |
| # return "Modelo no encontrado. Ejecuta primero: python finetune_xtts_peninsular_hf.py", None | |
| # tts = TTS(MODEL_PATH) | |
| # out_file = os.path.abspath("output.wav") | |
| # tts.tts_to_file(text=text, file_path=out_file, language="es") | |
| # return "Audio generado con acento peninsular", out_file | |
| #with gr.Blocks() as demo: | |
| # gr.Markdown("# XTTSv2 español peninsular") | |
| # text_input = gr.Textbox(label="Texto en español", lines=3) | |
| # btn = gr.Button("Generar audio") | |
| # status = gr.Label() | |
| # audio_out = gr.Audio(label="Resultado", type="filepath") | |
| # btn.click(fn=tts_infer, inputs=text_input, outputs=[status, audio_out]) | |
| #demo.launch( | |
| # server_name="0.0.0.0", | |
| # server_port=7860, # 🚨 Hugging Face espera el servicio en 7860 | |
| # share=False, | |
| # show_api=True # 👈 fuerza a que exponga los endpoints | |
| #) | |