Last active
December 19, 2015 06:59
-
-
Save tonytonyjan/5915569 to your computer and use it in GitHub Desktop.
Speech control plugin for Reveal.js.
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
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