Spaces:
Build error
Build error
box up
Browse files
app.py
CHANGED
@@ -94,50 +94,33 @@ def inference(audio, vocals, bass, drums, other, piano, guitar, lead_vocals, bac
|
|
94 |
print("Error in custom separation:", str(e))
|
95 |
return None
|
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 |
-
"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
|
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.
|
141 |
title=title,
|
142 |
description=description,
|
143 |
live=True # Enable live updates
|
|
|
94 |
print("Error in custom separation:", str(e))
|
95 |
return None
|
96 |
|
|
|
97 |
stem_files = {
|
98 |
+
"vocals": "./out/htdemucs_6s/test/vocals.wav",
|
99 |
+
"bass": "./out/htdemucs_6s/test/bass.wav",
|
100 |
+
"drums": "./out/htdemucs_6s/test/drums.wav",
|
101 |
+
"other": "./out/htdemucs_6s/test/other.wav",
|
102 |
+
"piano": "./out/htdemucs_6s/test/piano.wav",
|
103 |
+
"guitar": "./out/htdemucs_6s/test/guitar.wav",
|
104 |
+
"lead_vocals": primary_stem_path,
|
105 |
+
"backing_vocals": secondary_stem_path
|
106 |
}
|
107 |
|
108 |
# Filter out unchecked stems
|
109 |
+
selected_stems = [vocals, bass, drums, other, piano, guitar, lead_vocals, backing_vocals]
|
110 |
+
output_files = [stem_files[stem] if selected_stems[i] and os.path.isfile(stem_files[stem]) else None for i, stem in enumerate(stem_files)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
+
return output_files
|
113 |
|
114 |
# Checkbox for each stem
|
115 |
checkboxes = [gr.components.Checkbox(label=stem) for stem in ["Vocals", "Bass", "Drums", "Other", "Piano", "Guitar", "Lead Vocals", "Backing Vocals"]]
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
# Gradio Interface
|
118 |
title = "Source Separation Demo"
|
119 |
description = "Music Source Separation in the Waveform Domain. To use it, simply upload your audio and select the stems you want to display."
|
120 |
gr.Interface(
|
121 |
inference,
|
122 |
[gr.components.Audio(type="numpy", label="Input")] + checkboxes,
|
123 |
+
[gr.components.Audio(type="filepath", label=stem) for stem in ["Vocals", "Bass", "Drums", "Other", "Piano", "Guitar", "Lead Vocals", "Backing Vocals"]],
|
124 |
title=title,
|
125 |
description=description,
|
126 |
live=True # Enable live updates
|