Spaces:
Build error
Build error
Download app.py from Samueliyo/chatbot-miopia: direct link, hf CLI and curl.
- Browser
- Download file 945 Bytes
-
https://huggingface.co/spaces/Samueliyo/chatbot-miopia/resolve/main/app.py
- Command line
-
hf download hf://spaces/Samueliyo/chatbot-miopia/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Samueliyo/chatbot-miopia/resolve/main/app.py
945 Bytes
| import gradio as gr | |
| import whisper | |
| import requests | |
| # Cargar el modelo Whisper Medium | |
| modelo = whisper.load_model("medium") | |
| # URL del servidor LLaMA en Google Colab (se actualizará más adelante) | |
| LLAMA_SERVER_URL = "https://your-colab-server-url/run_llama" | |
| # Función para transcribir el audio y enviarlo a LLaMA 2 | |
| def transcribir_y_enviar(audio): | |
| transcripcion = modelo.transcribe(audio)["text"] | |
| # Enviar texto transcrito al servidor de LLaMA 2 en Google Colab | |
| respuesta = requests.post(LLAMA_SERVER_URL, json={"texto": transcripcion}) | |
| return respuesta.json().get("respuesta", "Error en el servidor de LLaMA") | |
| # Interfaz en Gradio | |
| interfaz = gr.Interface( | |
| fn=transcribir_y_enviar, | |
| inputs=gr.Audio(type="filepath"), | |
| outputs="text", | |
| title="Chatbot de Miopía Magna", | |
| description="Sube un audio y el chatbot responderá." | |
| ) | |
| # Ejecutar el servidor | |
| if __name__ == "__main__": | |
| interfaz.launch() | |