Spaces:
Sleeping
Sleeping
import os | |
import gradio as gr | |
from scipy.io.wavfile import write, read | |
import subprocess | |
def inference(audio): | |
# Erstellen eines Ausgabeordners, falls nicht vorhanden | |
os.makedirs("out", exist_ok=True) | |
# Schreiben der Eingabe-Audiodatei | |
write('mix.wav', audio[0], audio[1]) | |
# Ausführen des Demucs-Befehls | |
command = "python3 -m demucs -n mdx_extra_q -d cpu mix.wav -o out" | |
process = subprocess.run(command, | |
shell=True, | |
stdin=subprocess.DEVNULL, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE) | |
# Liste der erwarteten Ausgabedateien | |
files = ["./out/mdx_extra_q/mix/vocals.wav", | |
"./out/mdx_extra_q/mix/bass.wav", | |
"./out/mdx_extra_q/mix/drums.wav", | |
"./out/mdx_extra_q/mix/other.wav"] | |
# Überprüfen, ob die Ausgabedateien existieren | |
for file in files: | |
if not os.path.isfile(file): | |
print(f"File not found: {file}") | |
else: | |
print(f"File exists: {file}") | |
return files | |
# Artikel für die Interface-Beschreibung | |
article = "Inspired by </p>" | |
# Gradio Interface | |
demo = gr.Interface( | |
fn=inference, | |
inputs=gr.Audio(type="numpy", label="Input"), | |
outputs=[ | |
gr.Audio(type="filepath", label="Vocals"), | |
gr.Audio(type="filepath", label="Bass"), | |
gr.Audio(type="filepath", label="Drums"), | |
gr.Audio(type="filepath", label="Other") | |
], | |
article=article, | |
theme='syddharth/gray-minimal', | |
allow_flagging="never", | |
css="style.css" | |
) | |
# Starten des Gradio-Interfaces | |
demo.launch() | |