demo · v142
Voice Commands as Bias Grammar
The other obvious use case from the explainer thread: voice control. An app's command vocabulary is a closed set of short phrases — exactly the input phrases is designed for. The biaser nudges the recognizer toward the exact wording you want to match against. Press the mic and speak any of the buttons below; without biasing the recognizer routinely mishears "prev" as "pre" or "queue" as "cue".
biased phrase list
play pause next prev shuffle queue add to playlist volume up volume downsay a command…
no command matched yet
SpeechRecognition.phrases supported
—
commands recognised
0
The whole point of biased phrases is short, app-specific vocabulary: media controls, navigation, slot fillers for forms. With biasing on, "prev" should reliably resolve; with it off, recognisers tend to substitute the in-dictionary word that sounds closest.
relevant API
const sr = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
sr.lang = "en-US";
sr.continuous = true;
sr.interimResults = true;
sr.phrases = [
new SpeechRecognitionPhrase("play", 5.0),
new SpeechRecognitionPhrase("pause", 5.0),
new SpeechRecognitionPhrase("prev", 10.0), // strong bias
];
sr.start();