GAS17 commited on
Commit
e6a08fe
·
verified ·
1 Parent(s): de3d7cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
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, "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,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, "Audio isolation completed successfully."
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)
@@ -62,13 +62,12 @@ def isolate_audio(audio_file):
62
  # Create Gradio interface
63
  iface = gr.Interface(
64
  fn=isolate_audio,
65
- inputs=gr.Audio(type="filepath", label="Upload Audio File"),
66
  outputs=[
67
- gr.Audio(type="filepath", label="Isolated Audio"),
68
- gr.Textbox(label="Status")
 
69
  ],
70
- title="ElevenLabs Audio Isolation",
71
- description="Upload an audio file to isolate the main audio content using ElevenLabs API.",
72
  examples=[["sample_audio.mp3"]], # Add this line if you have a sample audio file
73
  )
74
 
 
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
  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)
 
62
  # Create Gradio interface
63
  iface = gr.Interface(
64
  fn=isolate_audio,
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
  examples=[["sample_audio.mp3"]], # Add this line if you have a sample audio file
72
  )
73