File size: 1,674 Bytes
434a20f
 
 
 
 
c7dd428
1b241af
434a20f
1b241af
 
434a20f
 
1b241af
434a20f
 
 
 
 
1b241af
434a20f
1b241af
434a20f
 
 
 
 
1b241af
434a20f
 
 
 
 
 
 
 
1b241af
a4a8e15
9e5caed
1b241af
434a20f
1b241af
c7dd428
1b241af
2cbbf97
 
 
 
1b241af
 
 
 
 
434a20f
 
1b241af
 
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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()