In examples for the Web Speech API, a grammar is always specified. For example, in MDN's colour change example, the grammar is:
#JSGF V1.0;
grammar colors;
public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;
However, in actually using the API (on Chrome 54.0.2840.71), the result function:
What then does the grammar actually do? How can I get either of these behaviours (restricting to the grammar and seeing the parse tree)?
The speech recognition part of the Web Speech API allows authorized Web applications to access the device's microphone and produces a transcript of the voice being recorded. This allows Web applications to use voice as one of the input & control method, similar to touch or keyboard.
Open the Google website on your desktop computer and you'll find a little microphone icon embedded inside the search box. Click the icon, say something and your voice is quickly transcribed into words.
The speech recognition interface lives on the browser's window object as SpeechRecognition in Firefox and as webkitSpeechRecognition in Chrome. Start by setting the recognition interface to SpeechRecognition (regardless of the browser) using: window. SpeechRecognition = window. webkitSpeechRecognition || window.
There's currently an open Chromium issue specifically about this:
https://bugs.chromium.org/p/chromium/issues/detail?id=799849&q=SpeechRecognition%20grammar&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With