Fixing the audio looping and pause narration issue

This commit is contained in:
2026-08-05 12:46:51 +02:00
parent f328759eab
commit d9dc9baa51
5 changed files with 134 additions and 33 deletions
+22
View File
@@ -71,6 +71,27 @@ def test_audio():
check("full render includes music with no seek", "music" in full and full["music"].src_offset == 0.0)
def test_crossfade_phase():
print("crossfade loop phase:")
# Looping pad with a 15s crossfade overlap: the crossfade stream repeats every
# (duration - overlap) = 60 - 15 = 45s, so a chunk starting at into=300 resumes
# at crossfade phase 300 % 45 = 30, while the hard-loop phase is 300 % 60 = 60→0.
audio = {"pad": AudioDefinition(file="pad.wav", loop=True, duration=60.0, overlap=15.0)}
markers = [MarkerTiming(marker_id="Apad", timestamp=0.0, context="", confidence=1.0)]
evs = {e.audio_id: e for e in _extract_audio_events(markers, audio, time_range=(300.0, 600.0))}
check("looping pad with overlap is included", "pad" in evs)
if "pad" in evs:
p = evs["pad"]
check("crossfade seeks to loop_len phase 30.0",
abs(p.crossfade_offset - 30.0) < 1e-6, f"crossfade_offset={p.crossfade_offset}")
check("src_offset still uses full-duration phase 0.0",
abs(p.src_offset - 0.0) < 1e-6, f"src_offset={p.src_offset}")
# Full render: no phase seek on either.
full = {e.audio_id: e for e in _extract_audio_events(markers, audio, time_range=None)}
check("full render pad has no crossfade seek",
"pad" in full and full["pad"].crossfade_offset == 0.0)
# ── video ────────────────────────────────────────────────────────────────────
def test_video():
print("video events:")
@@ -115,6 +136,7 @@ def test_video():
if __name__ == "__main__":
test_audio()
test_crossfade_phase()
test_video()
print()
if _fails: