Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,24 +4,27 @@ from scipy.io.wavfile import write, read
|
|
4 |
import subprocess
|
5 |
|
6 |
def 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.PIPE
|
17 |
-
)
|
18 |
|
19 |
-
#
|
20 |
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}")
|
@@ -29,23 +32,25 @@ def inference(audio):
|
|
29 |
print(f"File exists: {file}")
|
30 |
|
31 |
return files
|
32 |
-
|
33 |
-
article = "Inspired by <p><a href='https://github.com/facebookresearch/demucs' target='_blank'>Demucs</a></p>\n<p>Copyright © 2023 JP Madsen</p"
|
34 |
|
|
|
|
|
35 |
|
|
|
36 |
demo = gr.Interface(
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
48 |
)
|
49 |
|
50 |
-
#
|
51 |
-
demo.launch()
|
|
|
4 |
import subprocess
|
5 |
|
6 |
def inference(audio):
|
7 |
+
# Erstellen eines Ausgabeordners, falls nicht vorhanden
|
8 |
os.makedirs("out", exist_ok=True)
|
9 |
+
|
10 |
+
# Schreiben der Eingabe-Audiodatei
|
11 |
write('mix.wav', audio[0], audio[1])
|
12 |
|
13 |
+
# Ausführen des Demucs-Befehls
|
14 |
command = "python3 -m demucs -n mdx_extra_q -d cpu mix.wav -o out"
|
15 |
process = subprocess.run(command,
|
16 |
shell=True,
|
17 |
stdin=subprocess.DEVNULL,
|
18 |
stdout=subprocess.PIPE,
|
19 |
+
stderr=subprocess.PIPE)
|
|
|
20 |
|
21 |
+
# Liste der erwarteten Ausgabedateien
|
22 |
files = ["./out/mdx_extra_q/mix/vocals.wav",
|
23 |
"./out/mdx_extra_q/mix/bass.wav",
|
24 |
"./out/mdx_extra_q/mix/drums.wav",
|
25 |
"./out/mdx_extra_q/mix/other.wav"]
|
26 |
|
27 |
+
# Überprüfen, ob die Ausgabedateien existieren
|
28 |
for file in files:
|
29 |
if not os.path.isfile(file):
|
30 |
print(f"File not found: {file}")
|
|
|
32 |
print(f"File exists: {file}")
|
33 |
|
34 |
return files
|
|
|
|
|
35 |
|
36 |
+
# Artikel für die Interface-Beschreibung
|
37 |
+
article = "Inspired by <p><a href='https://github.com/facebookresearch/demucs' target='_blank'>Demucs</a></p>\n<p>Copyright © 2023 JP Madsen</p>"
|
38 |
|
39 |
+
# Gradio Interface
|
40 |
demo = gr.Interface(
|
41 |
+
fn=inference,
|
42 |
+
inputs=gr.inputs.Audio(type="numpy", label="Input"),
|
43 |
+
outputs=[
|
44 |
+
gr.outputs.Audio(type="filepath", label="Vocals"),
|
45 |
+
gr.outputs.Audio(type="filepath", label="Bass"),
|
46 |
+
gr.outputs.Audio(type="filepath", label="Drums"),
|
47 |
+
gr.outputs.Audio(type="filepath", label="Other")
|
48 |
+
],
|
49 |
+
article=article,
|
50 |
+
theme='syddharth/gray-minimal',
|
51 |
+
allow_flagging="never",
|
52 |
+
css="style.css"
|
53 |
)
|
54 |
|
55 |
+
# Starten des Gradio-Interfaces
|
56 |
+
demo.launch()
|