micro-wakeword
Local wake-word detection for Rust, powered by microWakeWord models.
micro-wakeword runs
microWakeWord-compatible
TensorFlow Lite models entirely on-device. Use the ready-made microphone
listener, or feed PCM from your own audio pipeline.
- Local inference: no cloud service or network connection
- Simple microphone API with resampling and channel conversion
- Low-level streaming API for files, sockets, bots, and custom audio engines
- Standard microWakeWord JSON support, plus a model-only builder
- Configurable cooldown, threshold, device, and TensorFlow Lite runtime
Microphone ──> Listener ─┐
├──> Detector ──> Detection { wake_word, probability }
Your 16 kHz PCM ─────────┘
[!NOTE] Windows x86-64 is supported out of the box. Other platforms currently need a compatible TensorFlow Lite C shared library supplied by the application.
Install
cargo add micro-wakeword
Windows builds require the MSVC C++ build tools because the audio frontend is compiled as part of the crate.
Quick start: listen to a microphone
use Listener;
The JSON file supplies the model path and its recommended detection settings. Relative model paths are resolved from the JSON file's directory.
Choose a microphone and cooldown
use Duration;
use Listener;
#
The default cooldown is one second. Use Duration::ZERO to disable repeat
suppression. List available inputs with available_input_devices().
Only have a .tflite model?
JSON is recommended, but it is not required. Provide the settings yourself:
use Listener;
#
The crate cannot infer the cutoff or sliding-window size from a TFLite file. Use values supplied by the model author when possible. Otherwise, validate them against recordings containing the wake word and recordings containing ordinary speech and background noise.
| Setting | Lower value | Higher value |
|---|---|---|
probability_cutoff |
More sensitive; more false activations | Stricter; more missed wake words |
sliding_window_size |
Faster; more affected by brief spikes | Steadier; slower to activate |
Bring your own audio
Use Detector when audio already comes from a file, WebSocket, voice bot,
media pipeline, or another capture library:
use ;
#
Each call requires exactly 160 samples of 16 kHz, mono, signed 16-bit
PCM—10 milliseconds of audio. The low-level detector does not resample,
downmix, or apply a cooldown. Call reset() before a new unrelated stream or
after an audio discontinuity.
Which API should I use?
| You have | Use |
|---|---|
| A microphone and model JSON | Listener::from_config |
| A microphone and only a TFLite model | Listener::builder |
| Your own decoded/resampled audio | Detector::from_config |
| Your own audio and only a TFLite model | Detector::builder |
Runnable examples
Commands below use the sample files in this repository's ../models folder:
| Example | Command |
|---|---|
| Microphone, devices, cooldown | cargo run --release --example listen -- ../models/miku.json --cooldown 0.5 |
| List microphones | cargo run --release --example listen -- --list-devices |
| TFLite model without JSON | cargo run --release --example model_only -- ../models/miku.tflite miku 0.3 3 |
| Process raw PCM directly | cargo run --no-default-features --example detect_pcm -- ../models/miku.json audio.raw |
| Supply a TFLite runtime | cargo run --no-default-features --example custom_runtime -- CONFIG.json tensorflowlite_c.dll |
| Inspect/reset a listener's detector | cargo run --release --example detector_access -- ../models/miku.json |
| Match individual error types | cargo run --release --example error_handling -- ../models/miku.json |
detect_pcm expects headerless little-endian i16 audio at 16 kHz mono. Omit
audio.raw to run it against generated silence.
TensorFlow Lite runtime
On Windows x86-64, Runtime::Auto uses this order:
MICRO_WAKEWORD_TFLITE_LIBTFLITE_C_LIB- The bundled, checksum-verified TensorFlow Lite 2.17.1 runtime
To choose a library explicitly:
use ;
#
Runtime::System searches the platform locations supported by tflite-c-rs.
Model compatibility
Models must use the standard microWakeWord pipeline:
- 16 kHz mono input audio
- 40 frontend features
- Signed int8 input tensor shaped
[1, rows, 40] - One int8, uint8, or float32 probability output
- Standard configuration format version 2 when using JSON
- 10 ms feature step
An incompatible model returns a descriptive error while loading.
Feature flags
The default listener feature enables CPAL microphone capture and Rubato
resampling. Applications supplying their own 16 kHz PCM can leave them out:
= { = "0.1", = false }
License
micro-wakeword is available under the MIT License. Bundled
TensorFlow microfrontend and KissFFT sources retain their upstream licenses;
see LICENSES.