Skip to content

Commit 94cd90b

Browse files
author
Zenflow
committed
fix: sort w2_proto by start time in step3_cut before bisect (whisper segment timestamps non-monotone)
1 parent af96597 commit 94cd90b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

scripts/podcast_to_moshi_dataset.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,14 @@ def step3_cut(ep_num: int, mp3_path: str, aligned: list) -> None:
739739
#
740740
# Working on a mutable list of floats avoids re-reading the aligned list N times.
741741

742-
# Collect only in-transcript words; build parallel start/end lists.
743-
w2_proto = [w for w in aligned if not w["out_of_transcript"]]
742+
# Collect only in-transcript words, sorted by start time.
743+
# Whisper segment boundaries can produce slightly non-monotone timestamps
744+
# (adjacent segments overlap by a few ms). bisect requires a sorted list,
745+
# so we sort here. The output w2 is then in strict chronological order.
746+
w2_proto = sorted(
747+
(w for w in aligned if not w["out_of_transcript"]),
748+
key=lambda w: w["start"],
749+
)
744750
starts = [w["start"] for w in w2_proto]
745751
ends = [w["end"] for w in w2_proto]
746752

0 commit comments

Comments
 (0)