Spaces:
Build error
Build error
boxes modify
Browse files
app.py
CHANGED
@@ -96,41 +96,49 @@ def inference(audio, vocals, bass, drums, other, piano, guitar, lead_vocals, bac
|
|
96 |
|
97 |
# Collecting all file paths
|
98 |
stem_files = {
|
99 |
-
"
|
100 |
-
"
|
101 |
-
"
|
102 |
-
"
|
103 |
-
"
|
104 |
-
"
|
105 |
-
"
|
106 |
-
"
|
107 |
}
|
108 |
|
109 |
# Filter out unchecked stems
|
110 |
selected_stems = {
|
111 |
-
"
|
112 |
-
"
|
113 |
-
"
|
114 |
-
"
|
115 |
-
"
|
116 |
-
"
|
117 |
-
"
|
118 |
-
"
|
119 |
}
|
120 |
|
121 |
-
return
|
122 |
|
123 |
# Checkbox for each stem
|
124 |
checkboxes = [gr.components.Checkbox(label=stem) for stem in ["Vocals", "Bass", "Drums", "Other", "Piano", "Guitar", "Lead Vocals", "Backing Vocals"]]
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
# Gradio Interface
|
127 |
title = "Source Separation Demo"
|
128 |
description = "Music Source Separation in the Waveform Domain. To use it, simply upload your audio and select the stems you want to display."
|
129 |
gr.Interface(
|
130 |
inference,
|
131 |
[gr.components.Audio(type="numpy", label="Input")] + checkboxes,
|
132 |
-
|
133 |
title=title,
|
134 |
description=description,
|
135 |
live=True # Enable live updates
|
136 |
-
).launch()
|
|
|
96 |
|
97 |
# Collecting all file paths
|
98 |
stem_files = {
|
99 |
+
"Vocals": "./out/htdemucs_6s/test/vocals.wav",
|
100 |
+
"Bass": "./out/htdemucs_6s/test/bass.wav",
|
101 |
+
"Drums": "./out/htdemucs_6s/test/drums.wav",
|
102 |
+
"Other": "./out/htdemucs_6s/test/other.wav",
|
103 |
+
"Piano": "./out/htdemucs_6s/test/piano.wav",
|
104 |
+
"Guitar": "./out/htdemucs_6s/test/guitar.wav",
|
105 |
+
"Lead Vocals": primary_stem_path,
|
106 |
+
"Backing Vocals": secondary_stem_path
|
107 |
}
|
108 |
|
109 |
# Filter out unchecked stems
|
110 |
selected_stems = {
|
111 |
+
"Vocals": vocals,
|
112 |
+
"Bass": bass,
|
113 |
+
"Drums": drums,
|
114 |
+
"Other": other,
|
115 |
+
"Piano": piano,
|
116 |
+
"Guitar": guitar,
|
117 |
+
"Lead Vocals": lead_vocals,
|
118 |
+
"Backing Vocals": backing_vocals
|
119 |
}
|
120 |
|
121 |
+
return {stem: stem_files[stem] if selected_stems[stem] and os.path.isfile(stem_files[stem]) else None for stem in selected_stems}
|
122 |
|
123 |
# Checkbox for each stem
|
124 |
checkboxes = [gr.components.Checkbox(label=stem) for stem in ["Vocals", "Bass", "Drums", "Other", "Piano", "Guitar", "Lead Vocals", "Backing Vocals"]]
|
125 |
|
126 |
+
# Custom output component function
|
127 |
+
def output_component(stem_results):
|
128 |
+
components = []
|
129 |
+
for stem, file_path in stem_results.items():
|
130 |
+
if file_path:
|
131 |
+
components.append(gr.Audio(file_path, label=stem))
|
132 |
+
return components
|
133 |
+
|
134 |
# Gradio Interface
|
135 |
title = "Source Separation Demo"
|
136 |
description = "Music Source Separation in the Waveform Domain. To use it, simply upload your audio and select the stems you want to display."
|
137 |
gr.Interface(
|
138 |
inference,
|
139 |
[gr.components.Audio(type="numpy", label="Input")] + checkboxes,
|
140 |
+
gr.outputs.Dynamic(output_component),
|
141 |
title=title,
|
142 |
description=description,
|
143 |
live=True # Enable live updates
|
144 |
+
).launch()
|