Spaces:
Running on Zero
Running on Zero
feat: make Load Audio button prominent and visible
Browse files- src/webui.py +23 -11
src/webui.py
CHANGED
|
@@ -292,22 +292,25 @@ if __name__ == '__main__':
|
|
| 292 |
show_file_upload_button = gr.Button('Upload file instead')
|
| 293 |
|
| 294 |
with gr.Column(visible=True) as file_upload_col:
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
# Hidden state to store the actual audio path from any source
|
| 298 |
-
audio_path_state = gr.Textbox(value="", label="Audio Path State", visible=False)
|
| 299 |
-
|
| 300 |
-
# Load from audios folder
|
| 301 |
gr.Markdown('### 📁 Load from Audios Folder')
|
| 302 |
with gr.Row():
|
| 303 |
folder_audio_dropdown = gr.Dropdown(
|
| 304 |
choices=get_audios_from_folder(),
|
| 305 |
label='Select audio from /audios folder',
|
| 306 |
-
info='Place your audio files in the "audios" folder and
|
| 307 |
interactive=True,
|
| 308 |
-
allow_custom_value=False
|
|
|
|
| 309 |
)
|
| 310 |
-
refresh_audio_btn = gr.Button('🔄 Refresh',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
|
| 312 |
if not IS_ZERO_GPU:
|
| 313 |
with gr.Row():
|
|
@@ -320,14 +323,23 @@ if __name__ == '__main__':
|
|
| 320 |
show_yt_link_button = gr.Button('Paste YouTube link/Path to local file instead', visible=False)
|
| 321 |
song_input_file.upload(process_file_upload, inputs=[song_input_file], outputs=[local_file, song_input])
|
| 322 |
|
| 323 |
-
# Connect folder audio
|
| 324 |
refresh_audio_btn.click(refresh_audio_list, outputs=folder_audio_dropdown)
|
| 325 |
-
|
|
|
|
|
|
|
| 326 |
load_selected_audio,
|
| 327 |
inputs=[folder_audio_dropdown],
|
| 328 |
outputs=[local_file, audio_path_state]
|
| 329 |
)
|
| 330 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
# When local_file changes (from upload/URL), also update state
|
| 332 |
def update_audio_state(x):
|
| 333 |
"""Extract path from gr.Audio output (could be tuple or string)."""
|
|
|
|
| 292 |
show_file_upload_button = gr.Button('Upload file instead')
|
| 293 |
|
| 294 |
with gr.Column(visible=True) as file_upload_col:
|
| 295 |
+
# Load from audios folder - PROMINENT POSITION
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
gr.Markdown('### 📁 Load from Audios Folder')
|
| 297 |
with gr.Row():
|
| 298 |
folder_audio_dropdown = gr.Dropdown(
|
| 299 |
choices=get_audios_from_folder(),
|
| 300 |
label='Select audio from /audios folder',
|
| 301 |
+
info='Place your audio files in the "audios" folder and click Refresh',
|
| 302 |
interactive=True,
|
| 303 |
+
allow_custom_value=False,
|
| 304 |
+
scale=4
|
| 305 |
)
|
| 306 |
+
refresh_audio_btn = gr.Button('🔄 Refresh List', variant='primary', scale=1)
|
| 307 |
+
|
| 308 |
+
load_from_folder_btn = gr.Button('▶️ LOAD SELECTED AUDIO', variant='secondary')
|
| 309 |
+
|
| 310 |
+
local_file = gr.Audio(label='Audio file (loaded here)', interactive=True, type="filepath")
|
| 311 |
+
|
| 312 |
+
# Hidden state to store the actual audio path from any source
|
| 313 |
+
audio_path_state = gr.Textbox(value="", label="Audio Path State", visible=False)
|
| 314 |
|
| 315 |
if not IS_ZERO_GPU:
|
| 316 |
with gr.Row():
|
|
|
|
| 323 |
show_yt_link_button = gr.Button('Paste YouTube link/Path to local file instead', visible=False)
|
| 324 |
song_input_file.upload(process_file_upload, inputs=[song_input_file], outputs=[local_file, song_input])
|
| 325 |
|
| 326 |
+
# Connect folder audio buttons - updates both audio player and state
|
| 327 |
refresh_audio_btn.click(refresh_audio_list, outputs=folder_audio_dropdown)
|
| 328 |
+
|
| 329 |
+
# Button click to load selected audio
|
| 330 |
+
load_from_folder_btn.click(
|
| 331 |
load_selected_audio,
|
| 332 |
inputs=[folder_audio_dropdown],
|
| 333 |
outputs=[local_file, audio_path_state]
|
| 334 |
)
|
| 335 |
|
| 336 |
+
# Also load on dropdown selection change (optional - can comment out if not wanted)
|
| 337 |
+
# folder_audio_dropdown.change(
|
| 338 |
+
# load_selected_audio,
|
| 339 |
+
# inputs=[folder_audio_dropdown],
|
| 340 |
+
# outputs=[local_file, audio_path_state]
|
| 341 |
+
# )
|
| 342 |
+
|
| 343 |
# When local_file changes (from upload/URL), also update state
|
| 344 |
def update_audio_state(x):
|
| 345 |
"""Extract path from gr.Audio output (could be tuple or string)."""
|