Cambiar interfaz para subir .wav en lugar de URL de YouTube
Browse files
app.py
CHANGED
|
@@ -1,34 +1,40 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from audio_pipeline import (
|
| 3 |
-
descargar_audio,
|
| 4 |
separar_audio_demucs,
|
| 5 |
limpiar_stems,
|
| 6 |
combinar_stems_sin_vocales,
|
| 7 |
reducir_ruido
|
| 8 |
)
|
| 9 |
|
| 10 |
-
def
|
| 11 |
-
# 1)
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
stems_dir = "separated
|
| 16 |
-
|
|
|
|
| 17 |
limpiar_stems(stems_dir)
|
| 18 |
-
|
|
|
|
| 19 |
combinar_stems_sin_vocales(stems_dir)
|
| 20 |
-
# 5) Reduce ruido
|
| 21 |
-
resultado = f"{stems_dir}/base_instrumental_clean.wav"
|
| 22 |
-
reducir_ruido(f"{stems_dir}/base_instrumental.wav", resultado)
|
| 23 |
-
return resultado
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
demo = gr.Interface(
|
| 26 |
-
fn=
|
| 27 |
-
inputs=gr.
|
| 28 |
-
outputs=gr.Audio(label="Base instrumental limpia"),
|
| 29 |
-
title="
|
| 30 |
-
description="
|
| 31 |
)
|
| 32 |
|
| 33 |
if __name__ == "__main__":
|
| 34 |
-
demo.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
from audio_pipeline import (
|
|
|
|
| 4 |
separar_audio_demucs,
|
| 5 |
limpiar_stems,
|
| 6 |
combinar_stems_sin_vocales,
|
| 7 |
reducir_ruido
|
| 8 |
)
|
| 9 |
|
| 10 |
+
def procesar_wav(input_wav_path):
|
| 11 |
+
# 1) Separa stems usando Demucs
|
| 12 |
+
# output_dir crear谩 carpeta como separated/<nombre_input>
|
| 13 |
+
separar_audio_demucs(input_wav_path, output_dir="separated")
|
| 14 |
+
base_name = os.path.splitext(os.path.basename(input_wav_path))[0]
|
| 15 |
+
stems_dir = os.path.join("separated", base_name)
|
| 16 |
+
|
| 17 |
+
# 2) Limpia cada stem (reducci贸n de ruido)
|
| 18 |
limpiar_stems(stems_dir)
|
| 19 |
+
|
| 20 |
+
# 3) Combina stems sin vocales
|
| 21 |
combinar_stems_sin_vocales(stems_dir)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
# 4) Reduce ruido en la base instrumental
|
| 24 |
+
wav_base = os.path.join(stems_dir, "base_instrumental.wav")
|
| 25 |
+
wav_clean = os.path.join(stems_dir, "base_instrumental_clean.wav")
|
| 26 |
+
reducir_ruido(wav_base, wav_clean)
|
| 27 |
+
|
| 28 |
+
return wav_clean
|
| 29 |
+
|
| 30 |
+
# Definimos la interfaz con un input tipo "upload" que nos da la ruta al archivo
|
| 31 |
demo = gr.Interface(
|
| 32 |
+
fn=procesar_wav,
|
| 33 |
+
inputs=gr.Audio(source="upload", type="filepath", label="Sube un archivo .wav"),
|
| 34 |
+
outputs=gr.Audio(type="filepath", label="Base instrumental limpia"),
|
| 35 |
+
title="Procesador de WAV a Base Instrumental",
|
| 36 |
+
description="Sube tu archivo WAV, separo stems, limpio vocales y reduzco ruido."
|
| 37 |
)
|
| 38 |
|
| 39 |
if __name__ == "__main__":
|
| 40 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|