Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -338,16 +338,12 @@ async def concat_story_audio(story: StoryCreationDTO, base_output: str, final_pa
|
|
| 338 |
bg_audio = AudioSegment.from_file(bg_file_wav)
|
| 339 |
|
| 340 |
# Adjust volume
|
| 341 |
-
bg_audio = bg_audio - (1 - scene.bgMusic.volume) *
|
| 342 |
# Loop if shorter than scene
|
| 343 |
if len(bg_audio) < len(scene_audio):
|
| 344 |
loops = (len(scene_audio) // len(bg_audio)) + 1
|
| 345 |
bg_audio = bg_audio * loops
|
| 346 |
bg_audio = bg_audio[:len(scene_audio)] # trim to match scene
|
| 347 |
-
|
| 348 |
-
# # fade out gradually (2 seconds)
|
| 349 |
-
# bg_audio = bg_audio.fade_out(2000)
|
| 350 |
-
|
| 351 |
scene_audio = scene_audio.overlay(bg_audio)
|
| 352 |
# os.remove(bg_file)
|
| 353 |
|
|
@@ -356,7 +352,7 @@ async def concat_story_audio(story: StoryCreationDTO, base_output: str, final_pa
|
|
| 356 |
chapter_audio += scene_audio
|
| 357 |
|
| 358 |
# Add 3 seconds of silence between chapters
|
| 359 |
-
chapter_audio += AudioSegment.silent(duration=
|
| 360 |
chapters_audio += chapter_audio
|
| 361 |
|
| 362 |
# Export final story
|
|
|
|
| 338 |
bg_audio = AudioSegment.from_file(bg_file_wav)
|
| 339 |
|
| 340 |
# Adjust volume
|
| 341 |
+
bg_audio = bg_audio - (1 - scene.bgMusic.volume) * 30 # approximate
|
| 342 |
# Loop if shorter than scene
|
| 343 |
if len(bg_audio) < len(scene_audio):
|
| 344 |
loops = (len(scene_audio) // len(bg_audio)) + 1
|
| 345 |
bg_audio = bg_audio * loops
|
| 346 |
bg_audio = bg_audio[:len(scene_audio)] # trim to match scene
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
scene_audio = scene_audio.overlay(bg_audio)
|
| 348 |
# os.remove(bg_file)
|
| 349 |
|
|
|
|
| 352 |
chapter_audio += scene_audio
|
| 353 |
|
| 354 |
# Add 3 seconds of silence between chapters
|
| 355 |
+
chapter_audio += AudioSegment.silent(duration=3000)
|
| 356 |
chapters_audio += chapter_audio
|
| 357 |
|
| 358 |
# Export final story
|