Skip to content

Commit ac19ee9

Browse files
author
Zenflow
committed
fix(pipeline): audit round 12 — F1–F3
F1 step1_transcribe (L313–325): When w1 is invalidated by a transcript sha256 mismatch, also delete ep{N}_w2aligned.json and ep{N}_anchor_offset.json if they exist. These step-2 caches store the anchor_offset calibrated against the old w1 timestamps. Without this cleanup, a fresh w1 (generated from a corrected transcript) would be fed into a stale step-2 cache — the old anchor_offset applied to new w1 timestamps produces silently wrong alignment with no warning. Matches the chunk-JSON invalidation pattern added in round 11. Each deleted file is printed for operator visibility. The deletion uses an os.path.exists guard (no unconditional remove). F2 process_episode (L1223): Added -> None return type annotation. Was the only public function in the file without a return annotation. F3 find_post_ad_anchor (L713): Narrowed return annotation from bare 'tuple | None' to 'tuple[int, int] | None'. The function always returns either None or (cand_si: int, anchor_wi: int). This was the last bare tuple annotation after round 11 parameterised step2_align.
1 parent 63cf811 commit ac19ee9

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

scripts/podcast_to_moshi_dataset.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,17 @@ def step1_transcribe(ep_num: int, mp3_path: str, transcript_path: str) -> tuple[
310310
):
311311
os.remove(stale_chunk)
312312
print(f" step1: staler Chunk-Cache gelöscht → {stale_chunk}", flush=True)
313+
# Also delete step-2 caches: w2aligned.json and anchor_offset.json
314+
# are derived from w1 timestamps. If w1 is regenerated, these are
315+
# stale — the anchor_offset calibrated against the old w1 would
316+
# produce a misaligned result when applied to the new w1.
317+
for stale_step2 in [
318+
os.path.join(WHISPER_CACHE, f"ep{ep_num}_w2aligned.json"),
319+
os.path.join(WHISPER_CACHE, f"ep{ep_num}_anchor_offset.json"),
320+
]:
321+
if os.path.exists(stale_step2):
322+
os.remove(stale_step2)
323+
print(f" step1: staler Step-2-Cache gelöscht → {stale_step2}", flush=True)
313324
# Fall through to re-transcription below.
314325
else:
315326
print(f" step1: w1 gültig — Transkription übersprungen ({w1_path})", flush=True)
@@ -703,7 +714,7 @@ def last_w1_end_before(t_exp: float) -> float | None:
703714
idx = bisect.bisect_right(w1_starts, t_exp, lo, hi) - 1
704715
return w1_ends[idx] if idx >= lo else None
705716

706-
def find_post_ad_anchor(si_e: int, t_exp_end: float) -> tuple | None:
717+
def find_post_ad_anchor(si_e: int, t_exp_end: float) -> tuple[int, int] | None:
707718
"""
708719
Findet den ersten zuverlässig bestätigten Anchor-Punkt in w1 für den
709720
w0-Inhalt nach dem END-Marker si_e.
@@ -1213,7 +1224,7 @@ def parse_episode_filter(spec: str) -> set:
12131224
return result
12141225

12151226

1216-
def process_episode(ep_num: int, transcript_path: str, mp3_path: str):
1227+
def process_episode(ep_num: int, transcript_path: str, mp3_path: str) -> None:
12171228
print(f"\n{'═' * 60}", flush=True)
12181229
print(f" Folge {ep_num}{os.path.basename(mp3_path)}", flush=True)
12191230
print(f"{'─' * 60}", flush=True)

0 commit comments

Comments
 (0)