3 Commits
Author SHA1 Message Date
HomerandClaude Fable 5.2 3046ad154a Wake phrases the model can hear: greeting x name, generated pieces, sensitivity
CI / check (push) Canceled after 0s
"Hey Lembas" could not work well: Lembas is not a word the model knows.

- The phrase is a greeting (Hey, OK, Hello) and a name (Assistant, Computer,
  Google, and ten ordinary names); the default is Hey Assistant and an old
  saved id reads as it.
- Token pieces are generated, not hand-written: fetch-wakeword.py also takes
  the model's bpe.model from the same pinned archive, gen-wake-phrases.py
  encodes every word with it into wake/WakeWords.kt, CI checks the committed
  table against the tokenizer, and WakeWordsTest checks every piece against
  tokens.txt. "OK" is spelled as the model's speech wrote it, OKAY.
  Elizabeth and Benjamin are dropped (four or more single-letter pieces).
- Each keyword line carries a boosting score and a trigger threshold
  (sherpa-onnx's ":boost #threshold"), chosen by a Sensitivity setting:
  Low 1.0/0.35, Normal 1.5/0.25, High 2.0/0.15; short phrases 0.05 stricter.
  numTrailingBlanks is the engine's own 1.
- Settings says the phrase is English whatever the app's language is, and
  that a Google device nearby answers to Google too.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 09:49:47 +00:00
HomerandClaude Fable 5.2 374574b9ce Wake word: the engine loads, and its state is one truth that is shown
CI / check (push) Canceled after 0s
The model was read from the APK with AssetManager.openFd, which throws for a
compressed asset; the assets were compressed, runCatching swallowed it, and
the engine never loaded on any phone.

- The model is copied out by stream, keyed by a version file the fetch
  script writes (a hash of the pinned model); onnx assets are stored.
- WakeState (Off, Starting, Listening, Paused, Failed) in one StateFlow that
  the service, its notification and Settings read. onStartCommand no longer
  posts the default phrase; the notification is written from the state only.
- WakeListener holds the loop apart from Android: an engine that does not
  load and a microphone that does not start or stops are Failed states with
  a reason, logged, retried with back-off; a new phrase cancels and joins the
  old loop before the engine is released.
- A keywords line is checked against tokens.txt before the engine sees it
  (the engine exits the process on an unknown piece).
- The service is not started without the microphone permission, and the app
  looks again each time it comes to the screen.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 09:44:49 +00:00
HomerandClaude Opus 5.5 dc642c62b9 Opt-in wake word: on-device keyword spotting in a microphone foreground service
CI / check (push) Canceled after 0s
- Engine: sherpa-onnx 2.0.1 keyword spotter (Apache-2.0) with the English
  zipformer-gigaspeech-3.3M KWS model (Apache-2.0, int8), fetched hash-pinned by
  scripts/fetch-wakeword.py into app/libs and src/full/assets (gitignored); CI and release run it.
  `full` flavour only (abiFilters arm64-v8a, armeabi-v7a, x86_64); `fdroid` has a stub engine
  and Settings says why. ProGuard keeps com.k2fsa.sherpa.onnx (JNI reads fields by name).
- WakeWordService (foregroundServiceType microphone): persistent notification with Stop; audio
  only to the engine in memory; pauses while the sheet is up (AssistPresence), in battery saver,
  and with the screen off unless Settings says otherwise. On the word: the sheet opens listening
  through LembasAssistService.showSession when LLeMbas is the assistant, else the activity,
  else a "tap to ask" notification.
- No microphone service at boot: WakeBootReceiver posts "tap to listen again"; MainActivity
  restarts a service the phone stopped.
- Settings › Assistant › Wake word: switch (off), four built-in English phrases (BPE-tokenized
  with the model's bpe.model), screen-on only, battery-optimisation page; privacy and cost text.
- The sheet's "no wake word" line now points at the setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 16:27:51 +00:00