File size: 1,765 Bytes
c48e3b9
ed3bea3
a8a043c
 
baab706
a8a043c
 
 
 
 
74aeff9
48d4cfa
baab706
 
 
48d4cfa
a8a043c
c48e3b9
48d4cfa
 
 
c48e3b9
48d4cfa
e34b8c9
baab706
 
48d4cfa
 
 
 
 
 
ed3bea3
74aeff9
a8a043c
ed3bea3
c55aa05
baab706
48d4cfa
 
 
 
 
 
baab706
 
48d4cfa
 
a8a043c
 
 
ed3bea3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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)