Skip to content

feat: add dictionaryOnly mode for background-safe G2P#14

Open
integrITsolutions wants to merge 1 commit into
mlalma:mainfrom
IntegrIT-Solutions:feat/dictionary-only-mode
Open

feat: add dictionaryOnly mode for background-safe G2P#14
integrITsolutions wants to merge 1 commit into
mlalma:mainfrom
IntegrIT-Solutions:feat/dictionary-only-mode

Conversation

@integrITsolutions
Copy link
Copy Markdown

Summary

Adds a dictionaryOnly property to EnglishG2P that skips the MLX BART OOV fallback while keeping pure-Swift dictionary lookups (179K entries) active.

Use case

iOS apps using MisakiSwift with Kokoro TTS crash with SIGABRT when the MLX BART fallback runs in background mode — Metal GPU work is prohibited by iOS in background processes. Setting g2p.dictionaryOnly = true prevents this while maintaining near-full pronunciation quality (only rare OOV words miss, which callers can handle with a fallback G2P).

Changes

  • Added public var dictionaryOnly: Bool = false on EnglishG2P
  • Guarded the two BART fallback call sites (fallback(w) for single words and fallback(token) for compound words) with !dictionaryOnly
  • Dictionary lookups (lexicon.transcribe) always run regardless of the flag
  • Zero behavior change when dictionaryOnly = false (default)

Testing

Tested in Voxnotes iOS app: foreground renders use full G2P, background renders use dictionary-only mode. Audio plays continuously through lock screen with consistent quality.

When `dictionaryOnly = true`, the MLX BART OOV fallback is skipped.
Pure Swift dictionary lookups (179K entries) still run, covering
virtually all English words. Only rare OOV words miss — those pass
through with nil phonemes for the caller to handle.

Use case: iOS background mode where Metal GPU is unavailable.
MLX crashes with SIGABRT ("Insufficient Permission to submit GPU
work from background") when the BART fallback runs. Dictionary-only
mode prevents this while maintaining near-full pronunciation quality.
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