Vocal / app.py
Offex's picture
Update app.py
11515d6 verified
raw
history blame contribute delete
659 Bytes
import gradio as gr
import subprocess
import os
import glob
import shutil
def separate(audio_path):
if os.path.exists("separated"):
shutil.rmtree("separated")
command = f"demucs --two-stems=vocals \"{audio_path}\""
subprocess.run(command, shell=True)
# find output automatically
vocals_file = glob.glob("separated/**/vocals.wav", recursive=True)[0]
music_file = glob.glob("separated/**/no_vocals.wav", recursive=True)[0]
return vocals_file, music_file
demo = gr.Interface(
fn=separate,
inputs=gr.Audio(type="filepath"),
outputs=[gr.File(), gr.File()],
title="AI Vocal Remover (Demucs)"
)
demo.launch()