| import os | |
| import gradio as gr | |
| from model_inference import ( | |
| inferir_basic_pitch | |
| ) | |
| def procesar_wav(input_wav_path: str): | |
| if not input_wav_path: | |
| return None | |
| try: | |
| # 1) Generar archivos midi | |
| midi_path = inferir_basic_pitch(input_wav_path) | |
| # Verificar que se generó el archivo | |
| if midi_path and os.path.exists(midi_path): | |
| return midi_path | |
| else: | |
| print("Error: No se pudo generar el archivo MIDI") | |
| return None | |
| except Exception as e: | |
| print(f"Error en procesar_wav: {e}") | |
| return None | |
| demo = gr.Interface( | |
| fn=procesar_wav, | |
| inputs=gr.Audio(label="Sube un stem (.wav)", type="filepath"), | |
| outputs=gr.File(label="Fichero Midi"), | |
| title="Basic Pitch Inference", | |
| description="Sube tu archivo de audio para generar el archivo midi correspondiente.", | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch(server_name="0.0.0.0", server_port=7860) |