gnosticdev commited on
Commit
a3d55f4
·
verified ·
1 Parent(s): 2fb6f64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -7,6 +7,7 @@ from pydub import AudioSegment
7
 
8
  load_dotenv()
9
 
 
10
  ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
11
  MUSICA_FONDO = os.path.join(ROOT_DIR, "musica.mp3")
12
  TAG1 = os.path.join(ROOT_DIR, "tag.mp3")
@@ -14,17 +15,21 @@ TAG2 = os.path.join(ROOT_DIR, "tag2.mp3")
14
 
15
  def mezclar_musica_y_tags(audio_path: str, custom_music_path: str = None) -> str:
16
  if not os.path.exists(audio_path):
17
- raise FileNotFoundError(f"Audio file not found: {audio_path}")
 
18
  podcast_audio = AudioSegment.from_file(audio_path)
19
  music_file = custom_music_path if custom_music_path and os.path.exists(custom_music_path) else MUSICA_FONDO
 
20
  if not os.path.exists(music_file):
21
- raise FileNotFoundError(f"Music file not found: {music_file}")
 
 
 
22
  if not os.path.exists(TAG1):
23
- raise FileNotFoundError(f"Tag file not found: {TAG1}")
24
  if not os.path.exists(TAG2):
25
- raise FileNotFoundError(f"Tag file not found: {TAG2}")
26
 
27
- musica_fondo = AudioSegment.from_file(music_file).apply_gain(-15)
28
  tag_outro = AudioSegment.from_file(TAG1).apply_gain(-5)
29
  tag_trans = AudioSegment.from_file(TAG2).apply_gain(-5)
30
 
 
7
 
8
  load_dotenv()
9
 
10
+ # Define paths relative to the root directory
11
  ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
12
  MUSICA_FONDO = os.path.join(ROOT_DIR, "musica.mp3")
13
  TAG1 = os.path.join(ROOT_DIR, "tag.mp3")
 
15
 
16
  def mezclar_musica_y_tags(audio_path: str, custom_music_path: str = None) -> str:
17
  if not os.path.exists(audio_path):
18
+ return f"Error: Audio file {audio_path} not found"
19
+
20
  podcast_audio = AudioSegment.from_file(audio_path)
21
  music_file = custom_music_path if custom_music_path and os.path.exists(custom_music_path) else MUSICA_FONDO
22
+
23
  if not os.path.exists(music_file):
24
+ return f"Error: Music file {music_file} not found"
25
+
26
+ musica_fondo = AudioSegment.from_file(music_file).apply_gain(-15)
27
+
28
  if not os.path.exists(TAG1):
29
+ return f"Error: Tag file {TAG1} not found"
30
  if not os.path.exists(TAG2):
31
+ return f"Error: Tag file {TAG2} not found"
32
 
 
33
  tag_outro = AudioSegment.from_file(TAG1).apply_gain(-5)
34
  tag_trans = AudioSegment.from_file(TAG2).apply_gain(-5)
35