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:
- Sometimes returns strings that do not fit the supplied grammar
- Does not provide the parse tree that describes the speech
What then does the grammar actually do? How can I get either of these behaviours (restricting to the grammar and seeing the parse tree)?