Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@ import gradio as gr
|
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
import uuid
|
| 5 |
-
import shutil
|
| 6 |
|
| 7 |
def clean_audio(audio_path):
|
| 8 |
uid = str(uuid.uuid4())
|
|
@@ -10,24 +9,25 @@ def clean_audio(audio_path):
|
|
| 10 |
|
| 11 |
os.makedirs(out_dir, exist_ok=True)
|
| 12 |
|
| 13 |
-
#
|
| 14 |
cmd = [
|
| 15 |
-
"demucs",
|
| 16 |
"-n", "htdemucs",
|
| 17 |
audio_path,
|
| 18 |
"-o", out_dir
|
| 19 |
]
|
| 20 |
subprocess.run(cmd, check=True)
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
)
|
|
|
|
| 25 |
|
| 26 |
return vocals_path
|
| 27 |
|
| 28 |
gr.Interface(
|
| 29 |
fn=clean_audio,
|
| 30 |
-
inputs=gr.Audio(type="filepath", label="Upload Audio"),
|
| 31 |
outputs=gr.Audio(type="filepath", label="Clean Vocals"),
|
| 32 |
title="AI Voice Cleaner & Vocal Remover",
|
| 33 |
description="Noise removal & vocal separation using Demucs (HF Spaces compatible)"
|
|
|
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
import uuid
|
|
|
|
| 5 |
|
| 6 |
def clean_audio(audio_path):
|
| 7 |
uid = str(uuid.uuid4())
|
|
|
|
| 9 |
|
| 10 |
os.makedirs(out_dir, exist_ok=True)
|
| 11 |
|
| 12 |
+
# Run demucs safely
|
| 13 |
cmd = [
|
| 14 |
+
"python", "-m", "demucs",
|
| 15 |
"-n", "htdemucs",
|
| 16 |
audio_path,
|
| 17 |
"-o", out_dir
|
| 18 |
]
|
| 19 |
subprocess.run(cmd, check=True)
|
| 20 |
|
| 21 |
+
# Find vocals.wav dynamically
|
| 22 |
+
model_dir = os.path.join(out_dir, "htdemucs")
|
| 23 |
+
song_dir = os.listdir(model_dir)[0]
|
| 24 |
+
vocals_path = os.path.join(model_dir, song_dir, "vocals.wav")
|
| 25 |
|
| 26 |
return vocals_path
|
| 27 |
|
| 28 |
gr.Interface(
|
| 29 |
fn=clean_audio,
|
| 30 |
+
inputs=gr.Audio(type="filepath", label="Upload Audio", max_length=60),
|
| 31 |
outputs=gr.Audio(type="filepath", label="Clean Vocals"),
|
| 32 |
title="AI Voice Cleaner & Vocal Remover",
|
| 33 |
description="Noise removal & vocal separation using Demucs (HF Spaces compatible)"
|