Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,11 +4,23 @@ from scipy.io.wavfile import write
|
|
| 4 |
|
| 5 |
|
| 6 |
def inference(audio):
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
title = "Demucs"
|
| 14 |
description = "Forked from here https://huggingface.co/spaces/akhaliq/demucs/ and changed to updated demucs pip source. Gradio demo for Demucs: Music Source Separation in the Waveform Domain. To use it, simply upload your audio, or click one of the examples to load them. Read more at the links below."
|
|
@@ -18,7 +30,10 @@ examples=[['test.mp3']]
|
|
| 18 |
gr.Interface(
|
| 19 |
inference,
|
| 20 |
gr.components.Audio(type="numpy", label="Input"),
|
| 21 |
-
[gr.components.Audio(type="filepath", label="Vocals"),
|
|
|
|
|
|
|
|
|
|
| 22 |
title=title,
|
| 23 |
description=description,
|
| 24 |
article=article,
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
def inference(audio):
|
| 7 |
+
os.makedirs("out", exist_ok=True)
|
| 8 |
+
write('test.wav', audio[0], audio[1])
|
| 9 |
+
result = os.system("python3 -m demucs.separate -n mdx_extra_q -d cpu test.wav -o out")
|
| 10 |
+
print(f"Demucs script result: {result}")
|
| 11 |
+
|
| 12 |
+
# Check if files exist before returning
|
| 13 |
+
files = ["./out/mdx_extra_q/test/vocals.wav",
|
| 14 |
+
"./out/mdx_extra_q/test/bass.wav",
|
| 15 |
+
"./out/mdx_extra_q/test/drums.wav",
|
| 16 |
+
"./out/mdx_extra_q/test/other.wav"]
|
| 17 |
+
for file in files:
|
| 18 |
+
if not os.path.isfile(file):
|
| 19 |
+
print(f"File not found: {file}")
|
| 20 |
+
else:
|
| 21 |
+
print(f"File exists: {file}")
|
| 22 |
+
|
| 23 |
+
return files
|
| 24 |
|
| 25 |
title = "Demucs"
|
| 26 |
description = "Forked from here https://huggingface.co/spaces/akhaliq/demucs/ and changed to updated demucs pip source. Gradio demo for Demucs: Music Source Separation in the Waveform Domain. To use it, simply upload your audio, or click one of the examples to load them. Read more at the links below."
|
|
|
|
| 30 |
gr.Interface(
|
| 31 |
inference,
|
| 32 |
gr.components.Audio(type="numpy", label="Input"),
|
| 33 |
+
[gr.components.Audio(type="filepath", label="Vocals"),
|
| 34 |
+
gr.components.Audio(type="filepath", label="Bass"),
|
| 35 |
+
gr.components.Audio(type="filepath", label="Drums"),
|
| 36 |
+
gr.components.Audio(type="filepath", label="Other")],
|
| 37 |
title=title,
|
| 38 |
description=description,
|
| 39 |
article=article,
|