File size: 659 Bytes
7c090f2 dc3dcb4 11515d6 dc3dcb4 7c090f2 dc3dcb4 11515d6 7c090f2 11515d6 7c090f2 11515d6 7c090f2 11515d6 7c090f2 dc3dcb4 11515d6 7c090f2 dc3dcb4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 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() |