Wake Word Confidence Threshold Simulator¶
Specification¶
The full specification below is extracted from Chapter 18: Audio Signal Processing, Sound Classification, and Speech I/O.
Type: microsim
**sim-id:** wake-word-confidence-threshold-simulator<br/>
**Library:** p5.js<br/>
**Status:** Specified
Learning objective: Students will *apply* (Bloom L3: Apply) a chosen confidence threshold to a stream of simulated wake-word detection scores, classifying each event as a true trigger, a false accept, or a missed detection.
Canvas: 700x450px default, responsive — recompute the strip-chart width from `windowWidth` in `windowResized()`.
Layout: a horizontally scrolling strip chart plotting a simulated audio confidence score (0 to 1 on the vertical axis) against time (horizontal axis) as simulated audio events stream past. A horizontal threshold line is drawn across the chart at the current slider value. A running tally box in the top-right corner shows live counts of "True Triggers," "False Accepts," and "Missed Detections."
Controls: a `createSlider()` labeled "Confidence Threshold" (range 0-1, step 0.01, default 0.5); a `createButton()` labeled "Generate New Test Run" that reseeds the simulated event stream; a `createButton()` labeled "Run / Pause."
Interaction: the underlying simulation generates a mix of two event types with different score distributions — true wake-word events (scores clustered high, mean around 0.8) and background noise events (scores clustered low, mean around 0.2), with some overlap so the threshold choice has real consequences. Each event crossing the threshold line lights up green if it was truly a wake-word event (true trigger) or red if it was actually background noise (false accept); a true wake-word event that stays under the threshold is marked with a small orange flag (missed detection). Clicking any past event on the strip chart reopens an infobox naming whether it was truly a wake-word or background event and showing its exact score, so a student can audit individual decisions rather than only the tally.
Implementation: p5.js, an array of event objects `{time, trueLabel, score}` generated from two different random distributions (`randomGaussian()` centered differently for wake-word versus background events). Redraw the full visible window each frame from the event array and current threshold value so moving the slider immediately re-colors past events and updates the tally.