# app.py import os import gradio as gr from audio_pipeline import ( separar_audio_demucs_6stems, limpiar_stems, combinar_stems_sin_vocales, reducir_ruido ) def procesar_wav(input_wav_path: str): # 1) Separar 6 stems con Demucs stems_dir = separar_audio_demucs_6stems(input_wav_path) # 2) Limpiar cada stem (_cleaned.wav) limpiar_stems(stems_dir) # 3) Recoger rutas a los 6 stems limpios labels = ["vocals", "drums", "bass", "guitar", "piano", "other"] stems_paths = [os.path.join(stems_dir, f"{lbl}_cleaned.wav") for lbl in labels] # 4) Generar base instrumental (mezcla sin vocals) combinar_stems_sin_vocales(stems_dir) base_raw = os.path.join(stems_dir, "base_instrumental.wav") # 5) Reducir ruido y normalizar la base clean_base = os.path.join(stems_dir, "base_instrumental_clean.wav") reducir_ruido(base_raw, clean_base) # 6) Devolver stems + base limpia return (*stems_paths, clean_base) demo = gr.Interface( fn=procesar_wav, inputs=gr.Audio(label="Sube un archivo .wav", type="filepath"), outputs=[ gr.Audio(label="Vocals limpio", type="filepath"), gr.Audio(label="Drums limpio", type="filepath"), gr.Audio(label="Bass limpio", type="filepath"), gr.Audio(label="Guitar limpio", type="filepath"), gr.Audio(label="Piano limpio", type="filepath"), gr.Audio(label="Other limpio", type="filepath"), gr.Audio(label="Base instrumental limpia", type="filepath"), ], title="Demucs 6-stems + Calidad Mejorada", description="Sube tu WAV y obtén 6 stems limpios (incluye guitarra) más la base instrumental mejorada." ) if __name__ == "__main__": demo.launch(server_name="0.0.0.0", server_port=7860)