Skip to content

Instantly share code, notes, and snippets.

@jamesmundy
Last active January 12, 2019 20:47
Show Gist options
  • Save jamesmundy/237fe55e41f15872f68fe11f760ba45f to your computer and use it in GitHub Desktop.
Save jamesmundy/237fe55e41f15872f68fe11f760ba45f to your computer and use it in GitHub Desktop.
if (annyang) {
// Let's define a command.
var commands = {
"(head for the) track": trackRecog,
"(into the) city": cityRecog,
"off road": offRoadRecog,
};
// Add our commands to annyang
annyang.addCommands(commands);
annyang.addCallback("resultMatch",
function (userSaid, commandText, phrases) {
console.log(userSaid);
console.log(commandText);
console.log(phrases);
stopListening();
});
annyang.start({ paused: true });
}
function beginListening() {
backgroundTrack.pause();
console.log("listening");
annyang.resume();
}
function stopListening() {
console.log("pausing listening");
annyang.pause();
backgroundTrack.play();
}
//Recognition Events
function offRoadRecog() {
replaceVideo(crv_off_1);
}
function trackRecog() {
replaceVideo(civic_track_1);
}
function cityRecog() {
replaceVideo(city_1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment