Skip to content

Instantly share code, notes, and snippets.

@neopunisher
Created May 26, 2018 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neopunisher/a204cd1fa2b01aa7fc625b0c37c2dc6e to your computer and use it in GitHub Desktop.
Save neopunisher/a204cd1fa2b01aa7fc625b0c37c2dc6e to your computer and use it in GitHub Desktop.
control stuff with your voice in the browser
(function(url, inj) {
inj(url).then(function() {
if (annyang) {
// Let's define a command.
var commands = {
'hello': function() { alert('Hello world!'); }
};
// Add our commands to annyang
annyang.addCommands(commands);
// Start listening.
annyang.start();
}
})
})('https://cdnjs.cloudflare.com/ajax/libs/annyang/2.6.0/annyang.min.js', (src, head = true) => new Promise(function(c, d) {
var a = document.createElement("script");
a.src = src;
a.type = "text/javascript";
a.onload = c;
a.onerror = d;
document[head ? 'head' : 'body'].appendChild(a)
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment