CoolFace
Apppublic

TogetherAI/Audio_split

sourceHugging Facemitupdated 3y agoView on Hugging Face
4likes
app.py52 linesDownload Raw Back to root
1import os2import gradio as gr3from scipy.io.wavfile import write, read4import subprocess5 6def inference(audio):7    8    os.makedirs("out", exist_ok=True)9    write('mix.wav', audio[0], audio[1])10 11    command = "python3 -m demucs -n mdx_extra_q -d cpu mix.wav -o out"12    process = subprocess.run(command, 13                             shell=True, 14                             stdin=subprocess.DEVNULL, 15                             stdout=subprocess.PIPE, 16                             stderr=subprocess.PIPE17                            )18 19    # Check if files exist before returning20    files = ["./out/mdx_extra_q/mix/vocals.wav",21             "./out/mdx_extra_q/mix/bass.wav",22             "./out/mdx_extra_q/mix/drums.wav",23             "./out/mdx_extra_q/mix/other.wav"]24    25    for file in files:26        if not os.path.isfile(file):27            print(f"File not found: {file}")28        else:29            print(f"File exists: {file}")30 31    return files32  33article = "Inspired by <p><a href='https://github.com/facebookresearch/demucs' target='_blank'>Demucs</a></p>\n<p>Copyright &copy; 2023 JP Madsen</p"34 35 36demo = gr.Interface(37  inference,38  gr.inputs.Audio(type = "numpy", label = "Input"), 39  [gr.outputs.Audio(type = "filepath", label = "Vocals"),40   gr.outputs.Audio(type = "filepath", label = "Bass"),41   gr.outputs.Audio(type = "filepath", label = "Drums"),42   gr.outputs.Audio(type = "filepath", label = "Other")43  ],44  article = article,45  theme = 'NoCrypt/miku@1.2.1',46  allow_flagging = "never",47  css="style.css",  # Hinzugefügt48)49 50#demo.queue(concurrency_count = 10)51demo.launch()52