Skip to content

feat(web): report the default TTS voice as active - #378

Open
ddfreiling wants to merge 3 commits into
Notalib:mainfrom
ddfreiling:feat/web-tts-default-voice
Open

ddfreiling wants to merge 3 commits into
Notalib:mainfrom
ddfreiling:feat/web-tts-default-voice

Conversation

@ddfreiling

Copy link
Copy Markdown
Member

Summary

Apps cannot show which voice web read-aloud uses until the user picks one, so voice pickers stay empty. The plugin picks that voice itself (pickDefaultVoice), using voice.default and the @readium/speech quality lists, which Dart doesn't have. This PR reports the pick through the existing ReaderTTSVoice.active field instead of adding API.

Change

  • Web: ttsGetAvailableVoices sets active: true on the voice pickDefaultVoice picks for each primary language, and false on the rest. The scoring stays in defaultVoice.ts.
  • Example app: with no voice chosen, the voice dropdown shows the active voice as "Name (default)", else "Select voice".
  • Docs: ADR 0003 records the picking logic, what active means per platform, and a follow-up for native. The TTS guide and the active doc comment point to it.

Review notes

  • active means different things per platform: the default pick on web, the app's chosen voice on Android, unset on iOS. A follow-up to report native defaults the same way would change Android's meaning, so the ADR leaves that as a separate decision.
  • The pick is computed per primary language (en), while speech uses the full tag (en-GB, +2 for an exact region). They differ only when several local, non-default voices of one language but different regions are installed and the text carries a region tag. The ADR names the exact alternative (use the open publication's language) and why it wasn't taken.
  • The marked voice is not pinned: it follows the book's language and the installed voices.

Verification

  • npm test (576 tests, including a new serializeVoices test), bin/typecheck, bin/format, bin/analyze, bin/changelog check.
  • Web example in Chrome on macOS: the plugin marked da-DK: Sara (Enhanced), en-GB: Daniel, de-DE: Anna, sv-SE: Alva. In a Danish book the dropdown showed "Sara (Enhanced) (default)". After choosing Magnus it showed "Magnus (Enhanced)".

Not covered

  • iOS and Android are unchanged and were not run. Their pickers still show "Select voice" until a voice is chosen; see the ADR's follow-up section.

ddfreiling and others added 3 commits November 30, 2026 17:37
Apps show an empty voice picker until the user chooses a voice,
because only the web plugin knows which voice pickDefaultVoice uses.
ttsGetAvailableVoices now sets active on that voice for each primary
language, so the scoring stays in defaultVoice.ts and no new API is
needed.

The example voice dropdown shows the active voice as "(default)" when
none is chosen. ADR 0003 records the per-platform meaning of active
and the native follow-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in use

On web, active marks the default voice and ignores ttsSetVoice, so
the old lead sentence misled apps into reading it as the current
voice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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