Update app.py
Browse files
app.py
CHANGED
|
@@ -1,36 +1,36 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
import
|
| 4 |
-
import
|
| 5 |
|
| 6 |
-
def
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
music = (left + right) / 2
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
sf.write("music.wav", music_audio, sr)
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
fn=vocal_remover,
|
| 27 |
-
inputs=gr.Audio(type="filepath", label="Upload Audio"),
|
| 28 |
outputs=[
|
| 29 |
gr.File(label="Vocals"),
|
| 30 |
gr.File(label="Music")
|
| 31 |
],
|
| 32 |
-
title="AI Vocal Remover",
|
| 33 |
-
description="
|
| 34 |
)
|
| 35 |
|
| 36 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
import os
|
| 4 |
+
import shutil
|
| 5 |
|
| 6 |
+
def separate(audio_path):
|
| 7 |
+
output_dir = "separated"
|
| 8 |
+
if os.path.exists(output_dir):
|
| 9 |
+
shutil.rmtree(output_dir)
|
| 10 |
|
| 11 |
+
cmd = [
|
| 12 |
+
"demucs",
|
| 13 |
+
"--two-stems=vocals",
|
| 14 |
+
audio_path
|
| 15 |
+
]
|
| 16 |
|
| 17 |
+
subprocess.run(cmd, check=True)
|
|
|
|
| 18 |
|
| 19 |
+
base = os.path.splitext(os.path.basename(audio_path))[0]
|
| 20 |
+
vocals = f"separated/htdemucs/{base}/vocals.wav"
|
| 21 |
+
music = f"separated/htdemucs/{base}/no_vocals.wav"
|
| 22 |
|
| 23 |
+
return vocals, music
|
|
|
|
| 24 |
|
| 25 |
+
demo = gr.Interface(
|
| 26 |
+
fn=separate,
|
| 27 |
+
inputs=gr.Audio(type="filepath", label="Upload Audio (max 2–3 min)"),
|
|
|
|
|
|
|
| 28 |
outputs=[
|
| 29 |
gr.File(label="Vocals"),
|
| 30 |
gr.File(label="Music")
|
| 31 |
],
|
| 32 |
+
title="🔥 REAL AI Vocal Remover (Demucs)",
|
| 33 |
+
description="Studio-quality vocal & music separation using deep learning"
|
| 34 |
)
|
| 35 |
|
| 36 |
+
demo.launch()
|