feat: speak filenames, paths and semantic versions - #50
Merged
Merged
Conversation
StuBehan
force-pushed
the
speak-filenames-and-versions
branch
from
September 8, 2026 12:49
63a9324 to
de7055f
Compare
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.
Two things in
normalize_for_speech- filenames and paths, then semantic versions.filenames
Turns out espeak already spells extensions correctly on its own.
.mdis "em dee",.tfis "tee eff",.jsonis "jason",.txtis "tee ex tee". So we leave the extension alone, respelling it would just regress the cases it gets right.What it gets wrong is everything around the extension. The dot is silent, so
README.mdcomes out "readmee-emdee" glued together. Hyphens get swallowed too, sospeech-normalizationis one long word. A leading dot is silent as well, so.githubis just "github", and~/glues into "tilde-slash".So now,
README.md-> "README dot md",docs/speech-normalization.md-> "docs slash speech normalization dot md",.github/workflows/ci.yml-> "dot github slash workflows slash ci dot yaml",src/cli.py:42-> "line 42 of cli dot py in src" - line number still leads because thats the signal, path trails as a prepositional phrase like you'd actually say it,.ymlis the one extension espeak really mangles (it reads as "immle"), so that aliases across to yaml.The bare-filename matcher is gated on an extension allowlist rather than any old
word.word, because prose is full of lookalikes espeak already reads fine -os.path.join,e.g.,U.S.,example.com. An allowlist drops all of those for free. Single-letter extensions are deliberately not in it (.c,.h) since they'd turnJ.R.Rinto "J dot R dot R", didn't feel worth the prose regression.Node.jsand friends are carved out by name.Nice side effect - spacing the dot fixed the dev-terms collision for nothing.
cli.pyused to come outC L I.pybecause.is a word boundary for\b. Now the stem is a standalone word, so the dict still corrects "kligh" to "see ell eye" and doesn't glue it on. No change to the dictionary at all.versions
versions_to_wordsalready handled the dotted digits, this does the rest of the semver string,1.2.3-rc.1glued into "three-arsee-one", now "1.2.3, rc 1",^,>and<are silent, so^1.2.3sounded identical to an exact pin! now "compatible with 1.2.3",1.xwas "one ex", now "1 dot x",And
>=was broken by us, not by espeak - the=unit rule was splitting it into> equals, and a bare>voices as literally nothing, so>=1.2.3was coming out as "equals 1 point 2 point 3". Which is the opposite of what it means. espeak reads an intact>=perfectly well, sospeak_versionshas to run beforeexpand_units. Theres an ordering note on it so we don't undo that later.Operators go semantic rather than literal - "at least", "at most", "above", "below", "exactly".
~was already mapping to "about" via the units rule which is accidentally the right sense for a tilde range, so thats untouched.Two guards in there worth keeping. Every operator needs a following digit so the rules stay in version context, and the boundary character gets re-emitted with a space so pip's glued
requests>=2.0doesn't fuse into "requestsat least". And a caret only counts at the start of a token, otherwisex^2became "x compatible with 2" 🤦Left
3.11alone. A two-part version is indistinguishable from a real decimal, where digit-by-digit is the correct reading (770.72-> "770 point 7 2"), so it needs a context heuristic rather than a rule change. There's a test pinning both together so the reasoning survives.flags
Both get their own switch.
filenamesis new, versions ride on the existingexpand_numbers, and theres a--no-filenameson the cli. Deliberately not ondev_terms- file refs used to be gated on that, which meant--no-dev-termssilently killed them too.checking
Worth saying I checked the readings by phonemizing rather than guessing, ie confirmed
README.mdgivesɹiːdmiː.ɛmdiːbefore deciding what to change. That's how the "extensions are already fine" thing turned up - my first assumption was that we needed to spell them out, and that would have been wasted work.236 tests, docs updated in
docs/speech-normalization.md.Does the "compatible with" wording for
^seem right, or would you rather it just said "caret"?