From f0387f24bbc63daacb597cb523338cecd1960728 Mon Sep 17 00:00:00 2001 From: jenstandstad Date: Fri, 8 May 2026 08:08:08 +0200 Subject: [PATCH] Adding support for audio again --- gnommo/cli.py | 2 +- gnommo/transformer.py | 29 ++++++++++++++++++----------- gnommo/validator.py | 3 +++ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/gnommo/cli.py b/gnommo/cli.py index c40de8e..25d6530 100644 --- a/gnommo/cli.py +++ b/gnommo/cli.py @@ -2071,7 +2071,7 @@ def _print_render_plan_details(plan, marker_timings, slides: dict) -> None: print(f" {time_str} [{marker_id}]") elif marker_id.startswith("audio:"): aligned_count += 1 - print(f" {time_str} [audio:{marker_id[1:]}]") + print(f" {time_str} [{marker_id}]") else: aligned_count += 1 print(f' {marker_id:6} {time_str} "{context}"') diff --git a/gnommo/transformer.py b/gnommo/transformer.py index 218a7d9..4a812b7 100644 --- a/gnommo/transformer.py +++ b/gnommo/transformer.py @@ -142,11 +142,15 @@ def _is_known_marker( if marker_id in CAMERA_PRESETS: return True - # Audio markers (A followed by id) + # Audio markers (A followed by id, e.g., Awoosh) or audio: prefix (e.g., audio:woosh) if marker_id.startswith("A") and len(marker_id) > 1: audio_id = marker_id[1:] if audio_id in audio or audio_id.isdigit(): return True + if marker_id.startswith("audio:") and audio is not None: + audio_id = marker_id[6:] + if audio_id in audio: + return True return False @@ -1014,19 +1018,22 @@ def _extract_audio_events( continue marker_id = timing.marker_id + audio_id = None if marker_id.startswith("A") and len(marker_id) > 1: audio_id = marker_id[1:] - if audio_id in audio: - if timing.timestamp < range_start or timing.timestamp >= range_end: - continue - start_time = max(0, timing.timestamp - AUDIO_OFFSET_SECONDS) - events.append( - AudioEvent( - audio_id=audio_id, - start_time=start_time, - audio_def=audio[audio_id], - ) + elif marker_id.startswith("audio:"): + audio_id = marker_id[6:] + if audio_id is not None and audio_id in audio: + if timing.timestamp < range_start or timing.timestamp >= range_end: + continue + start_time = max(0, timing.timestamp - AUDIO_OFFSET_SECONDS) + events.append( + AudioEvent( + audio_id=audio_id, + start_time=start_time, + audio_def=audio[audio_id], ) + ) return events diff --git a/gnommo/validator.py b/gnommo/validator.py index c4dfe1f..36d0045 100644 --- a/gnommo/validator.py +++ b/gnommo/validator.py @@ -57,6 +57,9 @@ def validate_project( # Skip audio markers (start with 'A' followed by audio id, e.g., Awoosh) if marker.startswith("A") and len(marker) > 1 and marker[1:].isalnum(): continue + # Skip audio: prefix markers (e.g., audio:woosh) + if marker.startswith("audio:"): + continue # Validate video trigger markers — both legacy [video:xxx] and # shorthand [vft:xxx] / [vfb:xxx] / [vst:xxx] / [vsb:xxx]. _VIDEO_PREFIXES = {