akshansh36 commited on
Commit
9f93bee
1 Parent(s): 8b1615b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -260,12 +260,17 @@ def process_audio(audio_file, uploaded_files, file_m, file_index):
260
  elif uploaded_files is not None:
261
  result, _ = run(uploaded_files, file_m, file_index)
262
 
263
- filenames = [os.path.basename(path) for path in result]
264
-
265
- return result, gr.update(choices=filenames, value=filenames[0], visible=True), result[0],result
 
 
 
266
 
267
- def update_audio_selection(selected_file):
268
- return gr.update(value=selected_file, visible=True)
 
 
269
 
270
 
271
  def switch_input(input_type):
 
260
  elif uploaded_files is not None:
261
  result, _ = run(uploaded_files, file_m, file_index)
262
 
263
+ # Create a mapping from filenames to full paths
264
+ file_mapping = {os.path.basename(path): path for path in result}
265
+ filenames = list(file_mapping.keys())
266
+
267
+ # Return the filenames for the dropdown, and the first file's path for initial playback
268
+ return file_mapping, gr.update(choices=filenames, value=filenames[0], visible=True), file_mapping[filenames[0]], result
269
 
270
+ def update_audio_selection(selected_filename, file_mapping):
271
+ # Use the selected filename to find the full path from the mapping
272
+ full_path = file_mapping[selected_filename]
273
+ return gr.update(value=full_path, visible=True)
274
 
275
 
276
  def switch_input(input_type):