Spaces:
Runtime error
Runtime error
HawkEye098432
commited on
Commit
•
6d30d13
1
Parent(s):
946a778
Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,16 @@ import gradio as gr
|
|
3 |
from scipy.io.wavfile import write
|
4 |
|
5 |
|
6 |
-
def
|
7 |
os.makedirs("out", exist_ok=True)
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
13 |
|
14 |
|
15 |
def download_file(filepath):
|
@@ -18,11 +21,11 @@ def download_file(filepath):
|
|
18 |
return file_bytes
|
19 |
|
20 |
|
21 |
-
title = "
|
22 |
description = "This is the latest 'bleeding edge version' which enables the new v4 Hybrid Transformer model. <br> for this space, 2 stem separation (Karaoke Mode) is enabled and CPU mode which has been optimized for best quality & processing time. <p>| Gradio demo for Demucs(v4): 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.</p>"
|
23 |
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> | <a href='https://www.thafx.com' target='_blank'>//THAFX</a></p>"
|
24 |
|
25 |
-
audio_input = gr.inputs.Audio(label="Input")
|
26 |
vocals_output = gr.outputs.Audio(label="Vocals", type="file", process=download_file)
|
27 |
instrumental_output = gr.outputs.Audio(label="No Vocals / Instrumental", type="file", process=download_file)
|
28 |
|
@@ -30,7 +33,7 @@ examples = [['test.mp3']]
|
|
30 |
|
31 |
# Create the Gradio interface
|
32 |
gr.Interface(
|
33 |
-
fn=
|
34 |
inputs=audio_input,
|
35 |
outputs=[vocals_output, instrumental_output],
|
36 |
title=title,
|
|
|
3 |
from scipy.io.wavfile import write
|
4 |
|
5 |
|
6 |
+
def inference(audio):
|
7 |
os.makedirs("out", exist_ok=True)
|
8 |
+
vocals_files = []
|
9 |
+
instrumental_files = []
|
10 |
+
for audio_file in audio:
|
11 |
+
write('test.wav', audio_file[0], audio_file[1])
|
12 |
+
os.system("python3 -m demucs.separate -n htdemucs --two-stems=vocals -d cpu test.wav -o out")
|
13 |
+
vocals_files.append("./out/htdemucs/test/vocals.wav")
|
14 |
+
instrumental_files.append("./out/htdemucs/test/no_vocals.wav")
|
15 |
+
return vocals_files, instrumental_files
|
16 |
|
17 |
|
18 |
def download_file(filepath):
|
|
|
21 |
return file_bytes
|
22 |
|
23 |
|
24 |
+
title = "Source Separation (v4)"
|
25 |
description = "This is the latest 'bleeding edge version' which enables the new v4 Hybrid Transformer model. <br> for this space, 2 stem separation (Karaoke Mode) is enabled and CPU mode which has been optimized for best quality & processing time. <p>| Gradio demo for Demucs(v4): 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.</p>"
|
26 |
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> | <a href='https://www.thafx.com' target='_blank'>//THAFX</a></p>"
|
27 |
|
28 |
+
audio_input = gr.inputs.Audio(label="Input", type="file", multiple=True)
|
29 |
vocals_output = gr.outputs.Audio(label="Vocals", type="file", process=download_file)
|
30 |
instrumental_output = gr.outputs.Audio(label="No Vocals / Instrumental", type="file", process=download_file)
|
31 |
|
|
|
33 |
|
34 |
# Create the Gradio interface
|
35 |
gr.Interface(
|
36 |
+
fn=inference,
|
37 |
inputs=audio_input,
|
38 |
outputs=[vocals_output, instrumental_output],
|
39 |
title=title,
|