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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -255,6 +255,9 @@ def run(audio_files, file_m, file_index):
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
@@ -267,6 +270,7 @@ def process_audio(audio_files, file_m, file_index):
267
 
268
 
269
 
 
270
  def model_conf():
271
  model_files = [f for f in os.listdir(model_dir) if f.endswith(".pth")]
272
  return gr.Dropdown(
@@ -316,6 +320,16 @@ def get_gui(theme):
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],
@@ -340,6 +354,7 @@ def get_gui(theme):
340
  return app
341
 
342
 
 
343
  if __name__ == "__main__":
344
  app = get_gui(theme)
345
  app.queue(default_concurrency_limit=40)
 
255
 
256
 
257
  def process_audio(audio_files, file_m, file_index):
258
+ # Clear previous audio outputs first
259
+ output_audio.clear()
260
+
261
  result, _ = run(audio_files, file_m, file_index)
262
 
263
  # Create a list of Audio components with filenames as labels
 
270
 
271
 
272
 
273
+
274
  def model_conf():
275
  model_files = [f for f in os.listdir(model_dir) if f.endswith(".pth")]
276
  return gr.Dropdown(
 
320
  def update_audio_column(audio_outputs):
321
  return gr.update(visible=True, children=audio_outputs)
322
 
323
+ # Reset the audio column visibility when new files are uploaded
324
+ def reset_audio_column():
325
+ return gr.update(visible=False, children=[])
326
+
327
+ aud.change(
328
+ reset_audio_column,
329
+ inputs=None,
330
+ outputs=output_audio
331
+ )
332
+
333
  button_base.click(
334
  process_audio,
335
  inputs=[aud, model, indx],
 
354
  return app
355
 
356
 
357
+
358
  if __name__ == "__main__":
359
  app = get_gui(theme)
360
  app.queue(default_concurrency_limit=40)