Created
March 26, 2015 17:51
-
-
Save lmccart/0f8de1a9481c71cb3d87 to your computer and use it in GitHub Desktop.
speech api + alchemy
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
var analyzing = false; | |
var recognition = new webkitSpeechRecognition(); | |
recognition.onresult = function(event) { | |
console.log(event) | |
var text = event.results[0][0].transcript; | |
if (analyzing == true) { | |
// check if stop word was said | |
if (text.indexOf('stop') !== -1) { | |
analyzing = false; | |
} | |
// otherwise analyze | |
else { | |
// send it to the alchemy api | |
// get data back, handle it, etc | |
} | |
} | |
else { | |
// check if start word was said | |
if (text.indexOf('start') !== -1) { | |
analyzing = true; | |
} | |
} | |
} | |
// you might also try logging errors and stops | |
recognition.onerror = function(event) { | |
} | |
recoginition.onend = function(event) { | |
} | |
recognition.start(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment