Created
June 9, 2013 09:44
-
-
Save jeshuamaxey/5742977 to your computer and use it in GitHub Desktop.
This is the bare minimum code to get voice dictation up and running with Chrome's new speech recognition API. Copy and paste into the JavaScript console, call the function and away you go.
This file contains hidden or 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
function setupDictation() { | |
var recognizer = new webkitSpeechRecognition(); | |
recognizer.continuous = true; | |
recognizer.interimResults = true; | |
recognizer.onresult = function(e) { | |
if (e.results.length) { | |
var lastResultIdx = e.resultIndex; | |
var message = e.results[lastResultIdx][0].transcript; | |
if(e.results[lastResultIdx].isFinal) { | |
console.log(message); | |
} | |
} | |
}; | |
recognizer.onend = function(e) { | |
console.log('dictation ended'); | |
}; | |
recognizer.start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment