Opt-in wake word: on-device keyword spotting in a microphone foreground service
CI / check (push) Canceled after 0s
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>
This commit is contained in:
31 files changed
+1181
-22
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package eu.llembas.android
|
||||
|
||||
import eu.llembas.android.wake.WakePause
|
||||
import eu.llembas.android.wake.WakePhrases
|
||||
import eu.llembas.android.wake.wakePause
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class WakeTest {
|
||||
@Test
|
||||
fun itListensOnlyWhenNothingStandsInTheWay() {
|
||||
assertEquals(WakePause.None, wakePause(screenOn = true, screenOnly = true, batterySaver = false, sheetOpen = false, micAllowed = true))
|
||||
assertEquals(WakePause.ScreenOff, wakePause(screenOn = false, screenOnly = true, batterySaver = false, sheetOpen = false, micAllowed = true))
|
||||
// Told to listen with the screen off too.
|
||||
assertEquals(WakePause.None, wakePause(screenOn = false, screenOnly = false, batterySaver = false, sheetOpen = false, micAllowed = true))
|
||||
assertEquals(WakePause.BatterySaver, wakePause(screenOn = true, screenOnly = true, batterySaver = true, sheetOpen = false, micAllowed = true))
|
||||
// The sheet has the microphone.
|
||||
assertEquals(WakePause.Assistant, wakePause(screenOn = true, screenOnly = true, batterySaver = true, sheetOpen = true, micAllowed = true))
|
||||
assertEquals(WakePause.NoMicrophone, wakePause(screenOn = true, screenOnly = true, batterySaver = false, sheetOpen = false, micAllowed = false))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun phrasesAreSpelledInTheModelsPieces() {
|
||||
assertEquals("hey_lembas", WakePhrases.byId("nonsense").id)
|
||||
// Every piece of the spelling starts a word with ▁ or continues one; no spaces inside a word.
|
||||
for (phrase in WakePhrases.all) {
|
||||
assertTrue(phrase.tokens.startsWith("▁"))
|
||||
assertEquals(phrase.words.split(' ').size, phrase.tokens.split(' ').count { it.startsWith("▁") })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -362,6 +362,7 @@ object Fakes {
|
||||
version = "1.0.0-beta.3",
|
||||
selfUpdate = true,
|
||||
phoneRecognizer = true,
|
||||
wakeAvailable = true,
|
||||
)
|
||||
|
||||
// The assistant's sheet, as it opens and as it answers.
|
||||
|
||||
Reference in new issue
Block a user