| 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) |
|
|
| |
| 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() |