Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
import os
|
| 4 |
+
import uuid
|
| 5 |
+
|
| 6 |
+
def clean_audio(audio):
|
| 7 |
+
uid = str(uuid.uuid4())
|
| 8 |
+
input_path = f"/tmp/{uid}.wav"
|
| 9 |
+
output_dir = f"/tmp/out_{uid}"
|
| 10 |
+
|
| 11 |
+
os.makedirs(output_dir, exist_ok=True)
|
| 12 |
+
|
| 13 |
+
# Save input
|
| 14 |
+
with open(input_path, "wb") as f:
|
| 15 |
+
f.write(audio)
|
| 16 |
+
|
| 17 |
+
# Demucs command
|
| 18 |
+
cmd = f"demucs -n htdemucs {input_path} -o {output_dir}"
|
| 19 |
+
subprocess.call(cmd, shell=True)
|
| 20 |
+
|
| 21 |
+
vocals = f"{output_dir}/htdemucs/{uid}/vocals.wav"
|
| 22 |
+
|
| 23 |
+
return vocals
|
| 24 |
+
|
| 25 |
+
gr.Interface(
|
| 26 |
+
fn=clean_audio,
|
| 27 |
+
inputs=gr.Audio(type="binary", label="Upload Audio"),
|
| 28 |
+
outputs=gr.Audio(label="Clean Vocals"),
|
| 29 |
+
title="AI Voice Cleaner & Vocal Remover",
|
| 30 |
+
description="Noise remove + music separation using Demucs"
|
| 31 |
+
).launch()
|