wakekit library
wakekit — wake word detection on-device, openWakeWord-compatible.
final models = await loadManifest(); final kit = await WakeKit.load(WakeKitOptions( model: models.firstWhere((m) => m.id == 'lada'), onHit: (score) => print('wake! $score'), )); final mic = await listenMic(kit); // later: await mic.stop(); await kit.dispose();
A detection means "the wake word was spoken" — nothing more. Whether your assistant should respond, and to what, is an app-level decision (same contract as the npm package's README). Audio never leaves the device: every model runs locally, no network call exists in this package.
Classes
- MicSession
-
A running microphone capture started by listenMic. The ecosystem idiom for "a thing you
stop" (StreamSubscription.cancel, Timer.cancel) — an object handle, not a bare function.
WakeKit.dispose()does NOT stop this: the session owns the mic, so forgetting stop leaves the microphone open until it's called (documented limitation, see the spec's edge table). - WakeKit
-
Loads the three ONNX models for one wake word and streams audio through them. One instance per
active wake word;
dispose()when done, then create a new one to switch words. - WakeKitOptions
-
Options for WakeKit.load. Callback-based, mirroring
WakeKitOptionsinsrc/index.ts:47-62— a Flutter-native pattern, and it keeps this README teachable side by side with the npm one. - WakeModel
-
One entry in
models/manifest.json— the model registry the manifest-driven picker (FR-6, FR-12) is built from. Never hand-construct thresholds or ids: read them from loadManifest. - WakeModelEval
-
Held-out measurement (unseen speakers) behind a model's
threshold— seescripts/eval.mjs.
Functions
-
listenMic(
WakeKit kit) → Future< MicSession> -
Requests mic permission, opens a 16 kHz mono PCM16 stream, and pushes it into
kit. Throws StateError if permission is denied or ifkitalready has an active mic session — two recorders feeding one pipeline would corrupt its mel/embedding buffers silently, not loudly. The requested rate is a request, not a fact (recordreports no negotiated rate) — chunks still route throughpush(_, 16000), so a mis-rated device is a documented limitation, not a crash. -
loadManifest(
) → Future< List< WakeModel> > -
Reads the bundled
models/manifest.json— the same file the npm package and demo page ship, synced byte-for-byte byscripts/sync-flutter-assets.mjs. Never hand-maintain a parallel list of ids/thresholds/labels; this is the single source of truth (CLAUDE.md). -
resampleLinear(
Float32List input, int inRate, int outRate) → Float32List