akshansh36 commited on
Commit
f09f1a3
·
verified ·
1 Parent(s): def470c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -28
app.py CHANGED
@@ -255,16 +255,8 @@ def run(audio_files, file_m, file_index):
255
 
256
 
257
  def process_audio(audio_files, file_m, file_index):
258
- result, first_audio = run(audio_files, file_m, file_index) # Extract the list of paths and the first path
259
-
260
- # Create a list of Audio components with filenames as labels
261
- audio_outputs = [
262
- gr.Audio(value=audio_path, label=os.path.basename(audio_path), visible=True, show_share_button=False)
263
- for audio_path in result
264
- ]
265
-
266
- return audio_outputs, result
267
-
268
 
269
 
270
 
@@ -314,25 +306,19 @@ def get_gui(theme):
314
  model = model_conf()
315
  indx = index_conf()
316
  button_base = button_conf()
317
- output_file = gr.File(label="Result", file_count="multiple", interactive=False)
318
- output_audio = gr.Column(visible=False) # This will be dynamically updated with audio components
319
-
320
- # Reset the audio column when new files are uploaded
321
- aud.change(
322
- lambda: gr.update(visible=False), # Reset visibility before new processing
323
- None,
324
- [output_audio]
325
- )
326
 
327
- # Handle the processing and output generation
328
  button_base.click(
329
- process_audio,
330
  inputs=[aud, model, indx],
331
- outputs=[output_audio, output_file],
332
- ).then(
333
- lambda audio_outputs: gr.update(visible=True),
334
- inputs=[output_audio],
335
- outputs=[output_audio]
336
  )
337
 
338
  gr.Examples(
@@ -342,12 +328,13 @@ def get_gui(theme):
342
  ],
343
  fn=process_audio,
344
  inputs=[aud, model, indx],
345
- outputs=[output_audio, output_file],
346
  cache_examples=False,
347
  )
348
 
349
  return app
350
 
 
351
  if __name__ == "__main__":
352
  app = get_gui(theme)
353
  app.queue(default_concurrency_limit=40)
@@ -358,4 +345,4 @@ if __name__ == "__main__":
358
  quiet=False,
359
  debug=False,
360
  allowed_paths=["./downloads/"],
361
- )
 
255
 
256
 
257
  def process_audio(audio_files, file_m, file_index):
258
+ result = run(audio_files, file_m, file_index)
259
+ return result # Only return the processed results
 
 
 
 
 
 
 
 
260
 
261
 
262
 
 
306
  model = model_conf()
307
  indx = index_conf()
308
  button_base = button_conf()
309
+ output_audio = gr.Column(visible=True) # This will hold dynamically created audio components
310
+
311
+ def display_audio_files(audio_paths):
312
+ audio_components = []
313
+ for audio_path in audio_paths:
314
+ audio_components.append(gr.Audio(value=audio_path, label=os.path.basename(audio_path), visible=True))
315
+ return audio_components
 
 
316
 
 
317
  button_base.click(
318
+ fn=process_audio,
319
  inputs=[aud, model, indx],
320
+ outputs=[output_audio],
321
+ _js=display_audio_files # Function to dynamically create and display audio components
 
 
 
322
  )
323
 
324
  gr.Examples(
 
328
  ],
329
  fn=process_audio,
330
  inputs=[aud, model, indx],
331
+ outputs=[output_audio],
332
  cache_examples=False,
333
  )
334
 
335
  return app
336
 
337
+
338
  if __name__ == "__main__":
339
  app = get_gui(theme)
340
  app.queue(default_concurrency_limit=40)
 
345
  quiet=False,
346
  debug=False,
347
  allowed_paths=["./downloads/"],
348
+ )