Upload app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,47 @@
|
|
1 |
-
import gradio as gr
|
2 |
import os
|
|
|
3 |
from scipy.io.wavfile import write
|
|
|
4 |
|
5 |
def inference(audio):
|
6 |
-
|
7 |
-
|
8 |
-
os.system("python3 -m demucs.separate -n htdemucs_ft test.wav -o out")
|
9 |
-
return "./out/htdemucs_ft/test/vocals.wav","./out/htdemucs_ft/test/bass.wav",\
|
10 |
-
"./out/htdemucs_ft/test/drums.wav","./out/htdemucs_ft/test/other.wav"
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
description=description,
|
24 |
-
article=article,
|
25 |
-
examples=examples
|
26 |
-
)
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
import gradio as gr
|
3 |
from scipy.io.wavfile import write
|
4 |
+
import subprocess
|
5 |
|
6 |
def inference(audio):
|
7 |
+
os.makedirs("out", exist_ok=True)
|
8 |
+
write('test.wav', audio[0], audio[1])
|
|
|
|
|
|
|
9 |
|
10 |
+
command = "python3 -m demucs.separate -n htdemucs_ft -d cpu test.wav -o out"
|
11 |
+
process = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
12 |
+
print("Demucs script output:", process.stdout.decode())
|
13 |
+
|
14 |
+
os.makedirs("out", exist_ok=True)
|
15 |
+
write('test.wav', audio[0], audio[1])
|
16 |
+
result = os.system("python3 -m demucs.separate -n htdemucs_ft -d cpu test.wav -o out")
|
17 |
+
print(f"Demucs script result: {result}")
|
18 |
|
19 |
+
# Check if files exist before returning
|
20 |
+
files = ["./out/htdemucs_ft/test/vocals.wav",
|
21 |
+
"./out/htdemucs_ft/test/bass.wav",
|
22 |
+
"./out/htdemucs_ft/test/drums.wav",
|
23 |
+
"./out/htdemucs_ft/test/other.wav"]
|
24 |
+
for file in files:
|
25 |
+
if not os.path.isfile(file):
|
26 |
+
print(f"File not found: {file}")
|
27 |
+
else:
|
28 |
+
print(f"File exists: {file}")
|
29 |
|
30 |
+
return files
|
31 |
+
|
32 |
+
title = "Demucs Very Slow"
|
33 |
+
description = ""
|
34 |
+
article = "<p style='text-align: center'><a href='' target='_blank'>Music Separation Very Slow</a> <a href='' target='_blank'></a></p>"
|
|
|
|
|
|
|
|
|
35 |
|
36 |
+
examples=[['test.mp3']]
|
37 |
+
gr.Interface(
|
38 |
+
inference,
|
39 |
+
gr.components.Audio(type="numpy", label="Input"),
|
40 |
+
[gr.components.Audio(type="filepath", label="Vocals"),
|
41 |
+
gr.components.Audio(type="filepath", label="Bass"),
|
42 |
+
gr.components.Audio(type="filepath", label="Drums"),
|
43 |
+
gr.components.Audio(type="filepath", label="Other")],
|
44 |
+
title=title,
|
45 |
+
description=description,
|
46 |
+
article=article
|
47 |
+
).launch(enable_queue=True)
|