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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -2,10 +2,10 @@ import gradio as gr
2
  from elevenlabs.client import ElevenLabs
3
  from elevenlabs.core.api_error import ApiError
4
  import os
 
5
  from dotenv import load_dotenv
6
  from pydub import AudioSegment
7
  import tempfile
8
- import shutil
9
 
10
  # Load environment variables
11
  load_dotenv()
@@ -44,7 +44,11 @@ def isolate_audio(audio_file):
44
  for chunk in isolated_audio_iterator:
45
  output_file.write(chunk)
46
 
47
- return output_file_path, "Audio isolation completed successfully."
 
 
 
 
48
  except ApiError as e:
49
  error_message = f"API Error: {e.body['detail']['message']}"
50
  return None, error_message
@@ -64,7 +68,8 @@ iface = gr.Interface(
64
  gr.Textbox(label="Status")
65
  ],
66
  title="ElevenLabs Audio Isolation",
67
- description="Upload an audio file to isolate the main audio content using ElevenLabs API."
 
68
  )
69
 
70
  # Launch the app
 
2
  from elevenlabs.client import ElevenLabs
3
  from elevenlabs.core.api_error import ApiError
4
  import os
5
+ import shutil
6
  from dotenv import load_dotenv
7
  from pydub import AudioSegment
8
  import tempfile
 
9
 
10
  # Load environment variables
11
  load_dotenv()
 
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, "Audio isolation completed successfully."
52
  except ApiError as e:
53
  error_message = f"API Error: {e.body['detail']['message']}"
54
  return None, error_message
 
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
 
75
  # Launch the app