You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
F1 (P1) Eliminate per-call norm_words() on w1 tokens in _try_match_seg.
Previously, every _try_match_seg call tokenised each w1 word in its
window via a list comprehension:
w_flat = [(norm_words(w1_words[k]["word"]) or [""])[0]
for k in range(w1_pos, win_end)]
For a 3-hour episode the anchor-search loop triggers this O(candidates
× w1_positions × window_size) times — easily tens of thousands of
redundant norm_words() calls on the same w1 text.
Fix: pre-compute a flat w1_nwords list (one normalised token per w1
entry) alongside w1_starts in both step2_align and
step3_build_skiplist, and pass it as a new w1_nwords parameter to
_try_match_seg. Inside _try_match_seg the window is now a zero-copy
list slice: w_flat = w1_nwords[w1_pos:win_end].
All four _try_match_seg call sites updated (step2: lines 452, 463;
step3: lines 681, 692). No behaviour change — identical normalisation
formula preserved.
F2 (P2) Add isinstance validation on w2aligned.json cache load in
process_episode. The step-2 fast-path did a bare json.load with no
shape check; a corrupt or schema-mismatched file produced a confusing
TypeError/KeyError deep inside step4_cut. Now raises ValueError with
the file path before any key access — consistent with w1 and chunk
cache guards added in round 4.
F3 (P2) wav_duration(): wrap float() conversion in try/except and
re-raise as RuntimeError naming the file path and raw ffprobe output.
ffprobe outputs "N/A" for files with no duration metadata (corrupt,
zero-byte, or stream-only WAV); float("N/A") previously produced a
generic ValueError with no context.
F4 (P3) mute_outside(): add defensive sorted(active) at function entry.
Cursor-based mute-region logic requires a sorted active list; callers
currently always pass merge_intervals() output (which sorts), but there
was no contract enforcement. Added sort + updated docstring to make
the invariant self-documenting and self-enforcing.
0 commit comments