Repository navigation
fix: join hyphenated and line-wrapped words for TTS - #44
Merged
Merged
Conversation
TTS spoke words like "evo- lution" as two utterances. Two causes: tokenizeForRSVP splits any hyphenated compound for RSVP display, and sentences.ts rejoined the pieces with a naive space-join; and line-end hyphens from hard-wrapped source text were only repaired on the EPUB path, and only when the joined form was already attested elsewhere in the book. sentences.ts now suppresses the space after a continuation token. A new shared lineWrap.ts resolver decides, per wrap, whether to join and whether to keep the hyphen (soft hyphen, digits, book-local attestation, capitalization, and a short safe-prefix list), and is wired into EPUB, PDF (including cross-page wraps), and the previously-unrepaired TXT and Markdown readers.
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.
Summary
tokenizeForRSVPsplits any hyphenated compound for RSVP display, andsentences.tsrejoined the pieces with a naive space-join; and line-end hyphens from hard-wrapped source text were only repaired on the EPUB path, and only when the joined form was already attested elsewhere in the book.sentences.tsnow suppresses the space after a-//continuation token when rebuilding utterance text.src/core/ingest/lineWrap.tsresolver decides, per line-end wrap, whether to join and whether to keep the hyphen (soft hyphen, digits/number-words, book-local attestation, capitalization, and a short safe-prefix list), defaulting to join-and-drop when unresolved.repairHardWraps), PDF (including cross-page-boundary wraps), and the previously-unrepaired TXT and Markdown readers.Test plan
npm test— 842 tests pass, including new coverage inlineWrap.test.ts,contentQuality.test.ts,pdfReader.test.ts,pdfLayout.test.ts,sentences.test.ts, and newplainTextReader.test.ts/markdownReader.test.tsnpx tsc --noEmitclean,npx eslintcleannpm run inspect:epubonpublic/pg1952-images.epubconfirms a real hard-wrap join ("a + long -> along") with no spurious issues introduced