GAS17 commited on
Commit
7e3d4c5
·
verified ·
1 Parent(s): ed6ad58

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -44,6 +44,21 @@ def isolate_audio(audio_file):
44
  for chunk in isolated_audio_iterator:
45
  output_file.write(chunk)
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  # Create Gradio interface
48
  iface = gr.Interface(
49
  fn=isolate_audio,
@@ -53,7 +68,6 @@ iface = gr.Interface(
53
  gr.File(label="Descargar audio convertido"),
54
  gr.Textbox(label="")
55
  ],
56
-
57
  )
58
 
59
  # Launch the app
 
44
  for chunk in isolated_audio_iterator:
45
  output_file.write(chunk)
46
 
47
+ # Copy the output file to a location that Gradio can access
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)
61
+
62
  # Create Gradio interface
63
  iface = gr.Interface(
64
  fn=isolate_audio,
 
68
  gr.File(label="Descargar audio convertido"),
69
  gr.Textbox(label="")
70
  ],
 
71
  )
72
 
73
  # Launch the app