Spaces:
Sleeping
Sleeping
| 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() | |