Skip to content

Instantly share code, notes, and snippets.

@tonytonyjan
Last active December 19, 2015 06:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonytonyjan/5915569 to your computer and use it in GitHub Desktop.
Save tonytonyjan/5915569 to your computer and use it in GitHub Desktop.
Speech control plugin for Reveal.js.
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.lang = 'cmn-Hant-TW';
recognition.onerror = function(event){console.error(event)}
recognition.onresult = function(event){
str = event.results[event.resultIndex][0].transcript
switch(true){
case /下一?頁$|next page$|next$/.test(str):
Reveal.next();
console.info(str);
break;
case /上一?頁$|previous page$|previous$/.test(str):
Reveal.prev();
console.info(str);
break;
default:
console.warn(str);
}
}
recognition.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment