Skip to content

Add a pronunciation list - #3

Merged
Kernel-Hunter merged 1 commit into
mainfrom
pronunciations
Nov 3, 2026
Merged

Kernel-Hunter merged 1 commit into
mainfrom
pronunciations

Conversation

@Kernel-Hunter

Copy link
Copy Markdown
Owner

Adds a pronunciation list to the web app, for names and terms the voice gets wrong.

What it does

  • More, Pronunciations opens a dialog with two fields: the word as written and how to say it, spelled the way it sounds ("Siobhan" as "shiv awn", "nginx" as "engine x"). A word selected in the document is filled in.
  • Listen plays the spelling with the current voice. Each saved entry can be edited in place, played or removed.
  • The list applies to every document and voice, to voice previews and to audio exports. Changing it drops the cached audio and, while reading, restarts from the current word, so you hear the change right away.
  • Matching is whole word and ignores case. "nginx's" and "nginx," match, "unginx" does not. Phrases of several words work, and the longest entry wins.
  • The list is kept in local storage (narrata.pronunciations), at most 500 entries. Nothing new goes over the network.
  • The Chrome extension does not use it yet. It runs the same worker with an empty list.

How

The worker gets the list in a new pronunciations message. Before the G2P runs, Pronouncer.rewrite replaces each listed word with its spelling and keeps a map from offsets in the new text to the original. The G2P tokens are mapped back, so every token from a spelling covers the original word. tokenTimings then gives that word the start of its first phoneme, as for any other word, and the highlight stays on the word on the page. Kokoro and Piper both go through this function.

Version

Bumps the version to 0.2.0 and adds CHANGELOG.md. After merging I will tag v0.2.0 for the extension zip.

Checks

  • Unit tests in tests/pronunciations.test.ts: cleaning the list, whole-word and phrase matching, the offset map, phonemes with the real G2P data, word timings, storage.
  • pnpm test, pnpm typecheck, pnpm build, pnpm build:ext and pnpm audit:licenses pass locally.
  • Production build in Chromium with the fast voice (Kristin): "Hermione and Siobhan read it." gave 1.88 s of audio and 5 word times without the list, and 2.33 s with 5 word times in order with it (timing method durations+tokens). Reading a test text with four entries highlighted all 22 words in order. Changing an entry during playback restarted at the current word and read to the end. A WAV export with the list finished.
  • Dialog checked at 1280 px, at 390 px and in the dark theme.

Under More, Pronunciations, people can add a word and how to say it,
spelled the way it sounds ("Siobhan" as "shiv awn"). A word selected in
the document is filled in, and Listen plays the spelling with the
current voice.

The worker replaces each listed word (whole words, any case, phrases
too) before the G2P and maps the tokens back to the original text, so
word timings and the highlight stay on the word on the page. It applies
to playback, previews and exports. Changing the list drops the cached
audio and restarts from the current word. The list is kept in local
storage.

Version 0.2.0, with a changelog.
@Kernel-Hunter
Kernel-Hunter merged commit fa1cae3 into main Nov 3, 2026
2 checks passed
@Kernel-Hunter
Kernel-Hunter deleted the pronunciations branch November 3, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant