akshansh36 commited on
Commit
d228293
1 Parent(s): edf4d66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -216,12 +216,15 @@ def apply_noisereduce(audio_list):
216
 
217
  return result
218
 
219
- def run(audio_file, file_m, file_index):
220
- if not audio_file:
221
  raise ValueError("Please provide an audio file.")
222
 
 
 
 
223
  try:
224
- duration_base = librosa.get_duration(filename=audio_file)
225
  print("Duration:", duration_base)
226
  except Exception as e:
227
  print(e)
@@ -252,16 +255,16 @@ def run(audio_file, file_m, file_index):
252
  respiration_median_filtering=r_m_f,
253
  envelope_ratio=e_r,
254
  consonant_breath_protection=c_b_p,
255
- resample_sr=44100 if audio_file.endswith('.mp3') else 0,
256
  )
257
  time.sleep(0.1)
258
 
259
- result = convert_now([audio_file], random_tag, converter)
260
 
261
  result = apply_noisereduce(result)
262
 
263
- # Since there's only one file, return its path for both download and playback
264
- return result[0]
265
 
266
 
267
  def model_conf():
@@ -297,7 +300,7 @@ def button_conf():
297
  )
298
 
299
  def output_conf():
300
- return gr.File(label="Download Processed Audio", interactive=False), gr.Audio(label="Play Processed Audio")
301
 
302
  def get_gui(theme):
303
  with gr.Blocks(theme=theme, delete_cache=(3200, 3200)) as app:
 
216
 
217
  return result
218
 
219
+ def run(audio_files, file_m, file_index):
220
+ if not audio_files:
221
  raise ValueError("Please provide an audio file.")
222
 
223
+ if isinstance(audio_files, str):
224
+ audio_files = [audio_files]
225
+
226
  try:
227
+ duration_base = librosa.get_duration(filename=audio_files[0])
228
  print("Duration:", duration_base)
229
  except Exception as e:
230
  print(e)
 
255
  respiration_median_filtering=r_m_f,
256
  envelope_ratio=e_r,
257
  consonant_breath_protection=c_b_p,
258
+ resample_sr=44100 if audio_files[0].endswith('.mp3') else 0,
259
  )
260
  time.sleep(0.1)
261
 
262
+ result = convert_now(audio_files, random_tag, converter)
263
 
264
  result = apply_noisereduce(result)
265
 
266
+ # Return the path of the processed audio file for both download and playback
267
+ return result, result[0] # Assuming `result` is a list of file paths
268
 
269
 
270
  def model_conf():
 
300
  )
301
 
302
  def output_conf():
303
+ return gr.File(label="Result", file_count="multiple", interactive=False), gr.Audio(label="Play Result")
304
 
305
  def get_gui(theme):
306
  with gr.Blocks(theme=theme, delete_cache=(3200, 3200)) as app: