Spaces:
Runtime error
Runtime error
Update app.py
#7
by
Hev832
- opened
app.py
CHANGED
@@ -2,25 +2,37 @@ import os
|
|
2 |
import gradio as gr
|
3 |
from scipy.io.wavfile import write
|
4 |
|
5 |
-
|
6 |
def inference(audio):
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
"./out/mdx_extra_q/test/
|
12 |
-
|
|
|
|
|
13 |
title = "Demucs"
|
14 |
description = "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 |
-
|
19 |
-
|
20 |
-
gr.
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
from scipy.io.wavfile import write
|
4 |
|
|
|
5 |
def inference(audio):
|
6 |
+
os.makedirs("out", exist_ok=True)
|
7 |
+
write('test.wav', audio[0], audio[1])
|
8 |
+
os.system("python3 -m demucs.separate -n mdx_extra_q -d cpu test.wav -o out")
|
9 |
+
return "./out/mdx_extra_q/test/vocals.wav", \
|
10 |
+
"./out/mdx_extra_q/test/bass.wav", \
|
11 |
+
"./out/mdx_extra_q/test/drums.wav", \
|
12 |
+
"./out/mdx_extra_q/test/other.wav"
|
13 |
+
|
14 |
title = "Demucs"
|
15 |
description = "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."
|
16 |
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>"
|
17 |
|
18 |
+
examples = [['test.mp3']]
|
19 |
+
|
20 |
+
with gr.Blocks() as demo:
|
21 |
+
gr.Markdown(f"## {title}")
|
22 |
+
gr.Markdown(description)
|
23 |
+
gr.Markdown(article)
|
24 |
+
|
25 |
+
with gr.Row():
|
26 |
+
with gr.Column():
|
27 |
+
audio_input = gr.Audio(label="Input Audio", type="numpy")
|
28 |
+
example_input = gr.Examples(examples=examples, inputs=audio_input)
|
29 |
+
submit_btn = gr.Button("Separate")
|
30 |
+
with gr.Column():
|
31 |
+
vocals_output = gr.Audio(label="Vocals")
|
32 |
+
bass_output = gr.Audio(label="Bass")
|
33 |
+
drums_output = gr.Audio(label="Drums")
|
34 |
+
other_output = gr.Audio(label="Other")
|
35 |
+
|
36 |
+
submit_btn.click(inference, inputs=audio_input, outputs=[vocals_output, bass_output, drums_output, other_output])
|
37 |
+
|
38 |
+
demo.launch()
|