Spaces:
Build error
Build error
radio button
Browse files
app.py
CHANGED
|
@@ -59,6 +59,7 @@
|
|
| 59 |
# ).launch()
|
| 60 |
|
| 61 |
|
|
|
|
| 62 |
import os
|
| 63 |
import gradio as gr
|
| 64 |
from scipy.io.wavfile import write
|
|
@@ -108,24 +109,29 @@ def inference(audio):
|
|
| 108 |
|
| 109 |
return existing_files
|
| 110 |
|
| 111 |
-
# Function to return selected audios
|
| 112 |
def get_selected_audios(stems, *selected_stems):
|
| 113 |
-
return [stems[stem] for stem in selected_stems if stem in stems]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
# Gradio Interface
|
| 116 |
title = "Source Separation Demo"
|
| 117 |
description = "Music Source Separation in the Waveform Domain. To use it, simply upload your audio."
|
| 118 |
|
| 119 |
-
audio_input = gr.
|
| 120 |
-
checkboxes = [gr.
|
| 121 |
-
|
| 122 |
|
| 123 |
gr.Interface(
|
| 124 |
fn=lambda audio, *args: get_selected_audios(inference(audio), *args),
|
| 125 |
-
inputs=[audio_input, *checkboxes],
|
| 126 |
-
outputs=
|
| 127 |
title=title,
|
| 128 |
description=description
|
| 129 |
).launch()
|
| 130 |
-
|
| 131 |
-
|
|
|
|
| 59 |
# ).launch()
|
| 60 |
|
| 61 |
|
| 62 |
+
|
| 63 |
import os
|
| 64 |
import gradio as gr
|
| 65 |
from scipy.io.wavfile import write
|
|
|
|
| 109 |
|
| 110 |
return existing_files
|
| 111 |
|
| 112 |
+
# Function to return selected audios along with their labels
|
| 113 |
def get_selected_audios(stems, *selected_stems):
|
| 114 |
+
return [(stem, stems[stem]) for stem in selected_stems if stem in stems and stems[stem]]
|
| 115 |
+
|
| 116 |
+
# Custom output component
|
| 117 |
+
def custom_output_component(label, filepath):
|
| 118 |
+
if filepath:
|
| 119 |
+
return gr.Audio(filepath, label=label, visible=True)
|
| 120 |
+
else:
|
| 121 |
+
return gr.Label("", visible=False)
|
| 122 |
|
| 123 |
# Gradio Interface
|
| 124 |
title = "Source Separation Demo"
|
| 125 |
description = "Music Source Separation in the Waveform Domain. To use it, simply upload your audio."
|
| 126 |
|
| 127 |
+
audio_input = gr.Audio(type="numpy", label="Input")
|
| 128 |
+
checkboxes = [gr.Checkbox(label=stem) for stem in ["vocals", "bass", "drums", "other", "piano", "guitar", "lead_vocals", "backing_vocals"]]
|
| 129 |
+
outputs = [gr.Dynamic(custom_output_component, label=stem) for stem in ["vocals", "bass", "drums", "other", "piano", "guitar", "lead_vocals", "backing_vocals"]]
|
| 130 |
|
| 131 |
gr.Interface(
|
| 132 |
fn=lambda audio, *args: get_selected_audios(inference(audio), *args),
|
| 133 |
+
inputs=[audio_input, *checkboxes],
|
| 134 |
+
outputs=outputs,
|
| 135 |
title=title,
|
| 136 |
description=description
|
| 137 |
).launch()
|
|
|
|
|
|