From 78ec4dd63a7474b54fc26ce932819e4f77167080 Mon Sep 17 00:00:00 2001 From: Maxim Vershinin Date: Wed, 2 Sep 2026 16:57:10 +0500 Subject: [PATCH] Fix #28: warn when timestamps overlap Add overlap detection in resolve_end_times. When consecutive tracks have overlapping time ranges (end of track N > start of track N+1), a warning is printed but processing continues as before. --- audio_splitter/timestamp.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/audio_splitter/timestamp.py b/audio_splitter/timestamp.py index aaab1c5..9b6ba11 100644 --- a/audio_splitter/timestamp.py +++ b/audio_splitter/timestamp.py @@ -73,4 +73,15 @@ def resolve_end_times(track_times, total_duration): if end_sec <= start_sec: raise ValueError(f"Track {idx+1}: end time ({end_sec}) is not after start ({start_sec})") resolved.append((start_sec, end_sec)) + + # Warn about overlapping intervals + for idx in range(len(resolved) - 1): + cur_end = resolved[idx][1] + next_start = resolved[idx + 1][0] + if cur_end > next_start: + print( + f"Warning: Track {idx+1} ends at {cur_end}s but Track {idx+2} starts at " + f"{next_start}s — timestamps overlap by {cur_end - next_start:.1f}s." + ) + return resolved -- 2.52.0