From 6cef15fa3ff5d31f4a6a419ce5dd4cc7c7191ae9 Mon Sep 17 00:00:00 2001 From: Prateek Chaplot Date: Tue, 24 Nov 2026 09:57:17 +0530 Subject: [PATCH 1/2] fix(timing): keep boundary phoneme samples so word starts match audio The engine dropped piper's BOS/EOS/pad alignments, discarding the sample counts that represent a sentence's leading and trailing silence. Reconcile then placed every word early by the leading silence and ended the last word before the trailing silence, so highlights led the voice by 60-320 ms and AC7's 100 ms target failed. Keep every alignment entry. reconcile already skips boundary phonemes when matching words while still advancing its sample cursor by their durations, and alignment counts now sum exactly to len(samples). T5.3 measured the defect. Dependent tasks: T1.2, T1.3, T5.1, T5.3. --- docs/ARCHITECTURE.md | 5 +++- docs/TASKS.md | 2 ++ src/tts/engine/piper_engine.py | 16 ++++++------ tests/integration/test_piper_engine.py | 5 +++- tests/unit/test_piper_engine.py | 4 +-- tests/unit/test_timing_reconcile.py | 34 ++++++++++++++++++++++++++ 6 files changed, 54 insertions(+), 12 deletions(-) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index e9a1353..b29ec30 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -268,7 +268,10 @@ tts/ char_end: int samples: "numpy.ndarray" # float32 PCM, mono sample_rate: int - phoneme_alignments: list[tuple[str, int]] # (phoneme, num_samples), BOS/EOS/pad excluded + phoneme_alignments: list[tuple[str, int]] # (phoneme, num_samples) in audio order, + # boundary markers (^ $ _) included so the + # counts sum to len(samples); timing skips + # them for word matching supports_alignments: bool # False → degraded mode @dataclass(frozen=True) diff --git a/docs/TASKS.md b/docs/TASKS.md index 7e7e8b2..e3b0c83 100644 --- a/docs/TASKS.md +++ b/docs/TASKS.md @@ -157,3 +157,5 @@ _All P4 tasks done._ - T5.1 results: 15/15 specs pass against the real `en_US-lessac-medium`, three consecutive runs (one from empty data dirs to prove voice seeding) at ~24 s each. AC11 runs on the fault server and proves the failed row has no `.wav`/`.part` while the main server's history total and a prior ready entry stay intact and restorable; AC12 cancels a 5,000-char slow-rate job and proves no partial file, no audio, no downloads; AC9/AC10 parse the downloaded WAV/SRT/VTT bytes (not API bodies) and cross-check download names, RIFF sizes, and cue timing; AC15 drives the whole flow with Tab/Enter/Space only. - T5.1 browser finding (recorded, no production change): a native `