akshansh36 commited on
Commit
e46d01a
·
verified ·
1 Parent(s): 2065479

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -255,13 +255,16 @@ 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)
259
 
260
- # Ensure first_audio is correctly formatted as a valid file path
261
- if not os.path.exists(first_audio):
262
- raise ValueError(f"Processed audio file not found at: {first_audio}")
 
 
263
 
264
- return result, gr.update(value=first_audio, visible=True)
 
265
 
266
 
267
  def model_conf():
@@ -300,19 +303,27 @@ def output_conf():
300
  return gr.File(label="Result", file_count="multiple", interactive=False), gr.Audio(label="Play Result",visible=False)
301
 
302
  def get_gui(theme):
303
- with gr.Blocks(theme=theme, delete_cache=(3200, 3200)) as app:
304
  gr.Markdown(title)
305
 
306
  aud = audio_conf()
307
  model = model_conf()
308
  indx = index_conf()
309
  button_base = button_conf()
310
- output_file, output_audio = output_conf()
 
 
 
 
311
 
312
  button_base.click(
313
  process_audio,
314
  inputs=[aud, model, indx],
315
  outputs=[output_file, output_audio],
 
 
 
 
316
  )
317
 
318
  gr.Examples(
@@ -328,6 +339,7 @@ def get_gui(theme):
328
 
329
  return app
330
 
 
331
  if __name__ == "__main__":
332
  app = get_gui(theme)
333
  app.queue(default_concurrency_limit=40)
 
255
 
256
 
257
  def process_audio(audio_files, file_m, file_index):
258
+ result, _ = run(audio_files, file_m, file_index)
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)
263
+ for audio_path in result
264
+ ]
265
 
266
+ return result, audio_outputs
267
+
268
 
269
 
270
  def model_conf():
 
303
  return gr.File(label="Result", file_count="multiple", interactive=False), gr.Audio(label="Play Result",visible=False)
304
 
305
  def get_gui(theme):
306
+ with gr.Blocks(theme=theme, css=".share-button { display: none !important; }") as app:
307
  gr.Markdown(title)
308
 
309
  aud = audio_conf()
310
  model = model_conf()
311
  indx = index_conf()
312
  button_base = button_conf()
313
+ output_file = gr.File(label="Result", file_count="multiple", interactive=False)
314
+ output_audio = gr.Column(visible=False)
315
+
316
+ def update_audio_column(audio_outputs):
317
+ return gr.update(visible=True, children=audio_outputs)
318
 
319
  button_base.click(
320
  process_audio,
321
  inputs=[aud, model, indx],
322
  outputs=[output_file, output_audio],
323
+ ).then(
324
+ update_audio_column,
325
+ inputs=[output_audio],
326
+ outputs=[output_audio]
327
  )
328
 
329
  gr.Examples(
 
339
 
340
  return app
341
 
342
+
343
  if __name__ == "__main__":
344
  app = get_gui(theme)
345
  app.queue(default_concurrency_limit=40)