Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -147,7 +147,7 @@ def add_slice_to_pack(current_preview, selection_list):
|
|
| 147 |
|
| 148 |
def clear_selection():
|
| 149 |
gr.Info("Selection cleared.")
|
| 150 |
-
return []
|
| 151 |
|
| 152 |
def create_final_pack(selection_list, progress=gr.Progress(track_tqdm=True)):
|
| 153 |
if not selection_list:
|
|
@@ -200,10 +200,10 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="red"))
|
|
| 200 |
slice_drums_btn = gr.Button("Visualize Slices", scale=1)
|
| 201 |
with gr.Row():
|
| 202 |
bass_output = gr.Audio(label="Bass", scale=4)
|
| 203 |
-
slice_bass_btn = gr.Button("
|
| 204 |
with gr.Row():
|
| 205 |
other_output = gr.Audio(label="Other / Instrumental", scale=4)
|
| 206 |
-
slice_other_btn = gr.Button("
|
| 207 |
|
| 208 |
gr.Markdown("### Slice Editor")
|
| 209 |
slice_plot = gr.Plot(label="Click a region on the waveform to preview a slice")
|
|
@@ -228,15 +228,13 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="red"))
|
|
| 228 |
slice_other_btn.click(fn=visualize_slices, inputs=other_output, outputs=[slice_plot, onset_times_state, active_stem_state])
|
| 229 |
|
| 230 |
# Correct event listener for plot interaction
|
| 231 |
-
slice_plot.
|
| 232 |
-
fn=preview_slice,
|
| 233 |
-
inputs=[active_stem_state, onset_times_state],
|
| 234 |
-
outputs=preview_player
|
| 235 |
-
)
|
| 236 |
|
| 237 |
add_to_pack_btn.click(fn=add_slice_to_pack, inputs=[preview_player, selected_slices_state], outputs=[selected_slices_state, selected_gallery])
|
| 238 |
-
clear_selection_btn.click(fn=clear_selection, outputs=selected_slices_state)
|
| 239 |
create_pack_btn.click(fn=create_final_pack, inputs=selected_slices_state, outputs=[download_zip_file, download_zip_file])
|
| 240 |
|
| 241 |
# --- Launch the UI ---
|
| 242 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
def clear_selection():
|
| 149 |
gr.Info("Selection cleared.")
|
| 150 |
+
return [], []
|
| 151 |
|
| 152 |
def create_final_pack(selection_list, progress=gr.Progress(track_tqdm=True)):
|
| 153 |
if not selection_list:
|
|
|
|
| 200 |
slice_drums_btn = gr.Button("Visualize Slices", scale=1)
|
| 201 |
with gr.Row():
|
| 202 |
bass_output = gr.Audio(label="Bass", scale=4)
|
| 203 |
+
slice_bass_btn = gr.Button("Slice", scale=1)
|
| 204 |
with gr.Row():
|
| 205 |
other_output = gr.Audio(label="Other / Instrumental", scale=4)
|
| 206 |
+
slice_other_btn = gr.Button("Slice", scale=1)
|
| 207 |
|
| 208 |
gr.Markdown("### Slice Editor")
|
| 209 |
slice_plot = gr.Plot(label="Click a region on the waveform to preview a slice")
|
|
|
|
| 228 |
slice_other_btn.click(fn=visualize_slices, inputs=other_output, outputs=[slice_plot, onset_times_state, active_stem_state])
|
| 229 |
|
| 230 |
# Correct event listener for plot interaction
|
| 231 |
+
slice_plot.select(fn=preview_slice, inputs=[active_stem_state, onset_times_state], outputs=preview_player)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
|
| 233 |
add_to_pack_btn.click(fn=add_slice_to_pack, inputs=[preview_player, selected_slices_state], outputs=[selected_slices_state, selected_gallery])
|
| 234 |
+
clear_selection_btn.click(fn=clear_selection, outputs=[selected_slices_state, selected_gallery])
|
| 235 |
create_pack_btn.click(fn=create_final_pack, inputs=selected_slices_state, outputs=[download_zip_file, download_zip_file])
|
| 236 |
|
| 237 |
# --- Launch the UI ---
|
| 238 |
+
# Use demo.launch() for Hugging Face Spaces
|
| 239 |
+
# Use demo.launch(debug=True) for local testing
|
| 240 |
+
demo.launch()
|