1

I'm using SpeechRecognition under Chromium (an interface of the Web Speech API) and have a grammar set for the recognition, defined in JSGF:

"#JSGF V1.0 UTF-8; grammar animal_list; public <animal> = dog | cat | horse ;"

It is successfully added to the recognition, so I would except that it would only return one of the three words (dog, cat, or horse) when I speak, but instead it continues to recognize anything I say.

First I thought the issue was with my code, but then I found that Mozilla made a live demo that illustrates this very use case of the API: You tell something, and if it is one of the colors defined in the grammar, the API recognizes it. This is how it was supposed to work I think.

But look at the bottom of the page for diagnostics messages: Whatever you tell it, it recognizes. Not just those colors defined in the grammar. As if the grammar wouldn't be there at all.

What do you think, should I report this as a bug of Chrome/Chromium and if so, where? Or do I misunderstand something how it is to work?

tom
  • 2,137
  • 2
  • 27
  • 51
  • They do not support grammars still. – Nikolay Shmyrev Jan 08 '18 at 11:37
  • 1
    Ok thanks, I posted a [bug report](https://bugs.chromium.org/p/chromium/issues/detail?id=799849), let's see if google does anything so the API conforms to W3C's recommendation – tom Jan 08 '18 at 12:50
  • @NikolayShmyrev How is the present question a duplicate of the linked question? – guest271314 Jan 10 '18 at 07:58
  • 1
    In SpeechRecognition, you can set the maxAlternatives variable to a big integer, and loop through the results until you find the predefined answers. Example: // Before calling start() recognition.maxAlternatives = 100; // in the onresult method recognition.onresult = (event) { /* Loop through event.results */ } – Ricardo Metring Aug 13 '20 at 20:13

0 Answers0