Pure Go streaming wake-word detection using microWakeWord v2 TFLite models. No CGo, no external C/C++ dependencies.
PCM 16 kHz ─► Audio Frontend ─► TFLite Interpreter ─► Sliding Avg ─► detected?
(mel features) (quantised int8) (probability)
- Audio frontend — 30 ms Hann window, 10 ms step, 512-point FFT, 40-channel mel filterbank (125–7500 Hz), spectral noise reduction, PCAN gain control, log scaling, int8 quantisation.
- TFLite interpreter — executes quantised int8 models with stateful resource variables (streaming). Supports the op subset used by MWW v2 models: Conv2D, DepthwiseConv2D, FullyConnected, Logistic, Quantize, Reshape, Concatenation, StridedSlice, SplitV, VarHandle, ReadVariable, AssignVariable, CallOnce.
- Sliding-window detection — averages the last N inference probabilities and compares against a cutoff threshold.
go get github.com/zserge/microwakeword@latest
package main
import (
"fmt"
"log"
mww "github.com/zserge/microwakeword"
)
func main() {
det, err := mww.NewDetector(mww.Config{
ModelPath: "hey_jarvis.tflite",
ProbabilityCutoff: 0.85,
SlidingWindowSize: 5,
FeaturesStepMs: 10,
})
if err != nil {
log.Fatal(err)
}
// Feed 16 kHz 16-bit signed PCM in any chunk size.
for chunk := range audioChunks() {
if det.ProcessAudio(chunk) {
fmt.Println("wake word detected")
det.Reset()
}
}
}Download .tflite models from the
micro-wake-word-models
repository. Use v2 models (input shape [1, 3, 40], int8).
Available wake words include: alexa, hey_jarvis, hey_mycroft,
okay_nabu, and others.
go run ./cmd/detect -model hey_jarvis.tflite -wav test.wav
Prints per-frame probabilities and reports detection time.
cd cmd/mic && go run . -model ../../testdata/hey_jarvis.tflite
Separate module (own go.mod) to isolate the
malgo dependency from the core
library. Listens on the default capture device and prints when the wake
word is detected.
go test ./...
Tests require .tflite model files and .wav audio samples in testdata/.
Tests are skipped automatically if the files are not present.
go test -bench=. -benchmem
On Mac M1 it's 50x faster than real-time (20ms to process 1s of audio).
microwakeword.go main API: Detector, Config, NewDetector, ProcessAudio
audiofrontend/ mel-spectrogram feature extraction (FFT, filterbank)
model/ TFLite FlatBuffer parser
interpreter/ quantised TFLite interpreter (MWW op subset)
cmd/detect/ offline WAV detection CLI
cmd/mic/ live microphone detection CLI (separate go.mod)
testdata/ test models and audio samples
MIT