Repository navigation
feat(timing): reconcile phoneme alignments into word timings - #9
Merged
Merged
Conversation
Map each sentence's per-phoneme sample counts to word-level timings with difflib matching, honest unaligned entries, and a 60% sentence collapse threshold.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task T1.3 from
docs/ARCHITECTURE.md§14.2 (§7.5). Implementsderive_word_timings(voice, result)plus thetts.timingpackage and 14 unit tests.What it does
WordTimingentries; punctuation and emoji stay attached to the text they belong to.difflib.SequenceMatcher.find_longest_matchfrom a per-sentence cursor.aligned=falseand a zero-width span after the previous word. A sentence whose aligned-token ratio is below 0.6 collapses to one unaligned entry spanning that sentence's audio.[previous_end, sentence_end], so they are ordered and monotonic even when ms rounding would otherwise collide.aligned_word_ratiocounts every token (a collapsed sentence contributes its token count as unaligned) and is-1.0whenSynthesisResult.supports_alignmentsis false or there are no sentences; degraded results are never phonemized.Decisions
timing/also adds an__init__.py— a package needs one; §6 lists onlyreconcile.py.^/$/_and espeak's" "from both sequences. Dropping the space is required because espeak expands numbers into several words (42→fˈɔːɹti tˈuː), and punctuation-only tokens such as—phonemize to nothing.split_wordsis exported so callers group text with the same tokenizer. Because a collapsed sentence yields exactly one entry, T1.6 should get per-sentence entry counts by deriving on a single-sentenceSynthesisResultinstead of assuming one entry per token.3/5stays,2/5collapses).Verification
pytest tests/unit→ 66 passed (14 new)pytest tests/integration→ 6 passed (realen_US-lessac-medium,TTS_DATA_DIR=.venv/tts-data)ruff check src/tts testsandruff format --check src/tts tests→ cleanmypy --strict src/tts→ cleangit diff --check→ clean—produced the expected zero-width unaligned entry. espeak expands 🙂 into "slightly smiling face", which reconciles honestly; the unit fixture uses a synthetic zero-phoneme voice instead.Environment note:
.venv/pytest-tmpis locked on this machine (WinError 5), so runs used fresh--basetemp .venv/ptmp-*directories. Tests pass.Suggested merge: squash merge with branch deletion (recommendation only; awaiting review).