Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,46 +1,24 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
-
import time
|
4 |
from scipy.io.wavfile import write
|
5 |
-
from gradio import components
|
6 |
|
7 |
-
def inference(audio):
|
8 |
-
os.makedirs("out", exist_ok=True)
|
9 |
-
write('test.wav', audio[0], audio[1])
|
10 |
-
os.system("python3 -m demucs.separate -n mdx_extra_q -d cpu test.wav -o out")
|
11 |
-
|
12 |
-
# Paths to the output files
|
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 |
-
|
18 |
-
# Check for the existence of the files
|
19 |
-
start_time = time.time()
|
20 |
-
while True:
|
21 |
-
if all(os.path.exists(file) for file in files):
|
22 |
-
break
|
23 |
-
elif time.time() - start_time > 30: # timeout after 30 seconds
|
24 |
-
raise TimeoutError("Timeout while waiting for output files to be created.")
|
25 |
-
time.sleep(1) # wait a bit before checking again
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
title = "Demucs"
|
30 |
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."
|
31 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1911.13254' target='_blank'>Music Source Separation in the Waveform Domain</a> | <a href='https://github.com/facebookresearch/demucs' target='_blank'>Github Repo</a></p>"
|
32 |
|
33 |
examples=[['test.mp3']]
|
34 |
-
|
35 |
gr.Interface(
|
36 |
inference,
|
37 |
-
components.Audio(type="numpy", label="Input"),
|
38 |
-
[
|
39 |
-
components.Audio(type="filepath", label="Vocals"),
|
40 |
-
components.Audio(type="filepath", label="Bass"),
|
41 |
-
components.Audio(type="filepath", label="Drums"),
|
42 |
-
components.Audio(type="filepath", label="Other")
|
43 |
-
],
|
44 |
title=title,
|
45 |
description=description,
|
46 |
article=article,
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
|
|
3 |
from scipy.io.wavfile import write
|
|
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
def inference(audio):
|
7 |
+
os.makedirs("out", exist_ok=True)
|
8 |
+
write('test.wav', audio[0], audio[1])
|
9 |
+
os.system("python3 -m demucs.separate -n mdx_extra_q -d cpu test.wav -o out")
|
10 |
+
return "./out/mdx_extra_q/test/vocals.wav","./out/mdx_extra_q/test/bass.wav",\
|
11 |
+
"./out/mdx_extra_q/test/drums.wav","./out/mdx_extra_q/test/other.wav"
|
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."
|
15 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1911.13254' target='_blank'>Music Source Separation in the Waveform Domain</a> | <a href='https://github.com/facebookresearch/demucs' target='_blank'>Github Repo</a></p>"
|
16 |
|
17 |
examples=[['test.mp3']]
|
|
|
18 |
gr.Interface(
|
19 |
inference,
|
20 |
+
gr.components.Audio(type="numpy", label="Input"),
|
21 |
+
[gr.components.Audio(type="filepath", label="Vocals"),gr.components.Audio(type="filepath", label="Bass"),gr.components.Audio(type="filepath", label="Drums"),gr.components.Audio(type="filepath", label="Other")],
|
|
|
|
|
|
|
|
|
|
|
22 |
title=title,
|
23 |
description=description,
|
24 |
article=article,
|