GAS17 commited on
Commit
75f7245
1 Parent(s): 7e3d4c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -22,10 +22,10 @@ def is_valid_audio(file_path):
22
 
23
  def isolate_audio(audio_file):
24
  if audio_file is None:
25
- return None, None, "Please upload an audio file."
26
 
27
  if not is_valid_audio(audio_file):
28
- return None, None, "The uploaded file is not a valid audio file. Please ensure it is a playable audio file."
29
 
30
  temp_dir = tempfile.mkdtemp()
31
  input_file_path = os.path.join(temp_dir, "input_audio.mp3")
@@ -48,13 +48,13 @@ def isolate_audio(audio_file):
48
  gradio_output_path = "gradio_output.mp3"
49
  shutil.copy2(output_file_path, gradio_output_path)
50
 
51
- return gradio_output_path, gradio_output_path, "Ruido de fondo eliminado del audio"
52
  except ApiError as e:
53
  error_message = f"API Error: {e.body['detail']['message']}"
54
- return None, None, error_message
55
  except Exception as e:
56
  error_message = f"An unexpected error occurred: {str(e)}"
57
- return None, None, error_message
58
  finally:
59
  # Clean up temporary files
60
  shutil.rmtree(temp_dir, ignore_errors=True)
@@ -65,7 +65,6 @@ iface = gr.Interface(
65
  inputs=gr.Audio(type="filepath", label=""),
66
  outputs=[
67
  gr.Audio(type="filepath", label=""),
68
- gr.File(label="Descargar audio convertido"),
69
  gr.Textbox(label="")
70
  ],
71
  )
 
22
 
23
  def isolate_audio(audio_file):
24
  if audio_file is None:
25
+ return None, "Please upload an audio file."
26
 
27
  if not is_valid_audio(audio_file):
28
+ return None, "The uploaded file is not a valid audio file. Please ensure it is a playable audio file."
29
 
30
  temp_dir = tempfile.mkdtemp()
31
  input_file_path = os.path.join(temp_dir, "input_audio.mp3")
 
48
  gradio_output_path = "gradio_output.mp3"
49
  shutil.copy2(output_file_path, gradio_output_path)
50
 
51
+ return gradio_output_path, "Ruido de fondo eliminado del audio"
52
  except ApiError as e:
53
  error_message = f"API Error: {e.body['detail']['message']}"
54
+ return None, error_message
55
  except Exception as e:
56
  error_message = f"An unexpected error occurred: {str(e)}"
57
+ return None, error_message
58
  finally:
59
  # Clean up temporary files
60
  shutil.rmtree(temp_dir, ignore_errors=True)
 
65
  inputs=gr.Audio(type="filepath", label=""),
66
  outputs=[
67
  gr.Audio(type="filepath", label=""),
 
68
  gr.Textbox(label="")
69
  ],
70
  )