I'm working with the HTML 5 speech input API and I want to let the server know which answers it can expect to be returned from the speech input. Is there a way to set a list of possible inputs?
-
Link to newer related question: http://stackoverflow.com/questions/16883609/is-web-speech-api-grammar-exposed-to-developers – Frison Alexander Apr 21 '14 at 18:38
-
Also https://stackoverflow.com/questions/7433801/grammar-in-google-web-speech-api – Nikolay Shmyrev Jul 07 '18 at 09:26
2 Answers
In Google Chrome you can not use grammars yet, overall they decided to use free-form recognition only. Relevant question is Grammar in Google speech API.
Grammars are supported in Firefox Web Speech API, but the feature is experimental.
If your browser supports HTML5 audio, you might want to try to recognize words from your grammar using Pocketsphinx.js library, it provides javascript-based recognizer which should be very good for grammars.

- 1
- 1

- 24,897
- 5
- 43
- 87
-
1I tried pocket sphinx, but it only hears me say 'four'. The rest of the time it's random results, sometimes 4-5 seconds after I stop talking. – Ronk Dec 07 '16 at 05:56
-
You can create a separate question about that. You need to provide all necessary details - what code do you run exactly and so on. – Nikolay Shmyrev Dec 07 '16 at 07:09
-
1I used the live demo on their website. Their code not mine. It would not work with Firefox Chrome or on Android or iOS for me... – Ronk Dec 07 '16 at 07:44
-
Which browser version exactly, which OS, what device? The more details you provide the faster you get solution to a problem. – Nikolay Shmyrev Dec 07 '16 at 10:30
-
1That pocketsphinx library really does not work. I have the same problem as @Ronk and I have lots of problems regarding City grammar. I would not install it. – Learn on hard way Mar 11 '20 at 01:21
-
I assume your a talking about the Speech Input API Specification as defined by the W3C. According to this specification grammars are supported, which is the method used by speech recognition systems to restrict possible inputs. Look for the section titled "Speech recognition grammars". The problem will be how well it is supported in the particular browser that is being used, which is the case for an HTML 5 specific function since it is not a completed standard yet. Chrome seems to be the most up to date with the standard. Checkout this blog post from the Chrome team on implementing the Speech Input API.

- 17,475
- 4
- 45
- 62
-
Chrome is the one that seems more reliable from my trials, but from the link above to an older question (4 years ago) it says Chrome has disabled the grammar usage for now... I would be happy JUST adjusting the weight of certain words, but it does not seem to want me to do that either. – Ronk Dec 07 '16 at 07:47
-
4Just to confirm, that as of April 2020, Chrome does not use provided grammars. No explicit error, just seems to ignore it completely. – Jamie F Apr 19 '20 at 20:11