Wake words and gestures
An always-on detector checks again and again, all day. Learn the trade-off between false alarms and misses, and how to choose a threshold.
In 60 seconds
Wake words and gestures
An always-on detector checks again and again, all day. Learn the trade-off between false alarms and misses, and how to choose a threshold.
How always-on detection works
- 1
Keep a rolling buffer
Store the last second or so of audio or motion in RAM. - 2
Check often
Several times a second, turn the latest window into features and run the model. - 3
Get a score
The model gives a score between 0 and 1: how likely the wake word is. - 4
Compare with a threshold
If the score is at or above the threshold, it fires. - 5
Smooth and wait
Often require a few high scores in a row, then ignore new triggers for a short time.
Two kinds of mistakes
| Mistake | What happens | How it feels |
|---|---|---|
| False alarm (false positive) | It fires when nobody said the word | The device wakes up for the TV or a pressure cooker whistle. Annoying, uses battery, and may feel like spying. |
| Miss (false negative) | Someone said the word and it did not fire | The user repeats themselves, gets frustrated, and gives up. |
Why false alarms need very small rates
# A detector that checks for the wake word twice every second, all day.
checks_per_day = 2 * 60 * 60 * 24
for false_alarm_rate in [0.01, 0.001, 0.0001, 0.00001]:
wakes = checks_per_day * false_alarm_rate
print(f"false alarm on {false_alarm_rate:.3%} of checks -> about {wakes:,.1f} false wakes a day")- Test only on clean recordings in a quiet room
- Report one accuracy number
- Pick the threshold that looks best on the training data
- Test with only the developer's voice
- Hours of real background: TV, family talk, traffic, festivals
- Report false alarms per hour and miss rate separately
- Choose the threshold on held-out data, for a false-alarm target
- Many voices, ages, accents and languages, near and far from the device
Watch and read more
Lab
Working functions that compute false-alarm and miss rates, and choose a threshold for a false-alarm target.
The problem
The starter makes made-up detector scores: 200 clips where someone said the wake word, and 5000 clips of other sounds.
- Write
rates(threshold). The detector fires when score ≥ threshold. Return(false_alarm_rate, miss_rate): the share of other clips that fire, and the share of word clips that do not. - Write
pick_threshold(max_false_alarm): among the candidate thresholds, return the lowest one whose false-alarm rate is at most the limit. (Lowest, because it misses the fewest real words.) - Run it. How many misses do you pay to go from a 1% false-alarm limit to 0.1%?
- Write two sentences: which mistake is worse for a kitchen voice switch, and which is worse for a "call for help" gesture?
Practice lab
Edit the code and run it. Python runs in your browser — nothing is sent to our server.
No output. Add print(...) to see values.
You are done when
Hard questions
Try to answer before you reveal. If you can answer these, you understood the lesson.
Q1With a 1% false-alarm limit you miss very few wake words. Why might that still be a bad product?Reveal
1% of checks is a lot for an always-on device. If it checks twice a second, that is well over a thousand false wakes a day. The limit should be set per hour or per day of real background sound, which means a much smaller rate per check.
Q2Your detector's false alarms are fine at home but very high at a wedding. What would you do?Reveal
Collect recordings from loud events with music, crowds and speeches, and add them to the background training data and to the false-alarm test. Then re-train and choose the threshold again. You might also require several high scores in a row. Check the miss rate again afterwards, because it may rise.
Questions people ask
Why not just make the model better, so no threshold is needed?
A better model helps: its scores separate the two groups more clearly, so any threshold gives fewer mistakes. But scores for real words and background will still overlap a bit, so you always need to choose a threshold.
What does "requiring several high scores in a row" do?
A single noisy spike above the threshold no longer fires. Real words usually give high scores over several checks in a row. This cuts false alarms, with a small delay and sometimes a few more misses.
Should every device use the same threshold?
Often one default is chosen, but some products adjust it by setting or environment. A noisy kitchen and a quiet bedroom are different. Test the default in the noisiest place you expect.
Can I pick any wake word?
Short or common words are easy to trigger by accident. Words with a few clear syllables that do not appear in normal talk usually work better. Test your choice against real speech in the languages your users speak.
Lesson test
5 questions. Get 3 right (60%) to pass and complete this lesson.