Created
July 9, 2019 16:06
-
-
Save erikdubbelboer/8e98d27a225189768ece7f472202150e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See: https://bugs.chromium.org/p/chromium/issues/detail?id=799849 | |
var grammar = '#JSGF V1.0; grammar commands; public <command> = left | right | jump | duck ;' | |
var recognition = new webkitSpeechRecognition(); | |
var speechRecognitionList = new webkitSpeechGrammarList(); | |
speechRecognitionList.addFromString(grammar, 1); | |
recognition.grammars = speechRecognitionList; | |
recognition.continuous = true; | |
recognition.lang = 'en-US'; | |
recognition.interimResults = false; | |
recognition.maxAlternatives = 1; | |
recognition.onresult = function(e) { | |
var command = e.results[e.results.length - 1][0].transcript; | |
console.log(command); | |
}; | |
recognition.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment