Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,13 +7,23 @@ from pydub import AudioSegment
|
|
7 |
|
8 |
load_dotenv()
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
13 |
|
14 |
def mezclar_musica_y_tags(audio_path: str, custom_music_path: str = None) -> str:
|
|
|
|
|
15 |
podcast_audio = AudioSegment.from_file(audio_path)
|
16 |
music_file = custom_music_path if custom_music_path and os.path.exists(custom_music_path) else MUSICA_FONDO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
musica_fondo = AudioSegment.from_file(music_file).apply_gain(-15)
|
18 |
tag_outro = AudioSegment.from_file(TAG1).apply_gain(-5)
|
19 |
tag_trans = AudioSegment.from_file(TAG2).apply_gain(-5)
|
@@ -24,7 +34,7 @@ def mezclar_musica_y_tags(audio_path: str, custom_music_path: str = None) -> str
|
|
24 |
musica_fondo_loop = musica_fondo_loop[:duracion_podcast]
|
25 |
|
26 |
mezcla = musica_fondo_loop.overlay(podcast_audio)
|
27 |
-
mezcla = mezcla + tag_outro
|
28 |
|
29 |
silent_ranges = []
|
30 |
for i in range(0, len(podcast_audio) - 500, 100):
|
|
|
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")
|
13 |
+
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)
|
|
|
34 |
musica_fondo_loop = musica_fondo_loop[:duracion_podcast]
|
35 |
|
36 |
mezcla = musica_fondo_loop.overlay(podcast_audio)
|
37 |
+
mezcla = mezcla + tag_outro
|
38 |
|
39 |
silent_ranges = []
|
40 |
for i in range(0, len(podcast_audio) - 500, 100):
|