Created
February 27, 2014 06:19
-
-
Save marchawkins/9245335 to your computer and use it in GitHub Desktop.
** Chrome only ** First test with the [annyang javascript library](https://www.talater.com/annyang/ "annyang javascript library"), a 2k library for allowing users to issue voice commands via their browser. If viewing this page over **http** versus **https**, your browser will ask for permission to use your microphone. The demo will only work if …
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
<div class="panel panel-default"> | |
<div class="panel-heading">Speech Recognition Status</div> | |
<div class="panel-body"> | |
<div id="status"></div> | |
</div> | |
</div> | |
<script src="/assets/js/annyang.min.js"/> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script> | |
"use strict"; | |
// first we make sure annyang started succesfully | |
if (annyang) { | |
// define the functions our commands will run. | |
var hello = function() { | |
$("#status").text('hello.'); | |
}; | |
// define our commands. | |
// * The key is what you want your users to say say. | |
// * The value is the action to do. | |
// You can pass a function, a function name (as a string), or write your function as part of the commands object. | |
var commands = { | |
'hello (there)': hello | |
}; | |
// OPTIONAL: activate debug mode for detailed logging in the console | |
annyang.debug(); | |
// Add voice commands to respond to | |
annyang.addCommands(commands); | |
// OPTIONAL: Set a language for speech recognition (defaults to English) | |
annyang.setLanguage('en'); | |
// Start listening. You can call this here, or attach this call to an event, button, etc. | |
annyang.start(); | |
} else { | |
$(document).ready(function() { | |
$("#status").text('Sorry, browser not supported.'); | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment