Speech KITT
> A flexible GUI for interacting with Speech Recognition
KITT makes it easy to add a GUI to pages using Speech Recognition. Whether you are using annyang, a different library or even webkitSpeechRecognition directly, KITT will take care of the GUI.
Hello World
The most basic implementation requires 6 commands.
- Let KITT know how to start and stop the SpeechRecognition engine you use with
SpeechKITT.setStartCommand()
and SpeechKITT.setAbortCommand
. - Add events to your SpeechRecognition engine so it calls
SpeechKITT.onStart()
when it starts, and SpeechKITT.onEnd()
when it stops. - Tell KITT which stylesheet to use for its GUI with
SpeechKITT.setStylesheet()
(KITT comes with a number of pre-made styles). - Start your engines with
SpeechKITT.vroom()
<script src="//cdnjs.cloudflare.com/ajax/libs/SpeechKITT/0.3.0/speechkitt.min.js"></script>
<script>
var recognition = new webkitSpeechRecognition();
SpeechKITT.setStartCommand(function() {recognition.start()});
SpeechKITT.setAbortCommand(function() {recognition.abort()});
recognition.addEventListener('start', SpeechKITT.onStart);
recognition.addEventListener('end', SpeechKITT.onEnd);
SpeechKITT.setStylesheet('//cdnjs.cloudflare.com/ajax/libs/SpeechKITT/0.3.0/themes/flat.css');
SpeechKITT.vroom();
</script>
Hello World - With annyang
If you're doing Speech Recognition with annyang, you can skip most of the configuration above. Just calling SpeechKITT.annyang()
will take care of the configuration explained in steps 1 & 2 above.
<script src="//cdnjs.cloudflare.com/ajax/libs/annyang/2.1.0/annyang.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/SpeechKITT/0.3.0/speechkitt.min.js"></script>
<script>
if (annyang) {
annyang.addCommands({
'hello': function() { alert('Hello world!'); }
});
SpeechKITT.annyang();
SpeechKITT.setStylesheet('//cdnjs.cloudflare.com/ajax/libs/SpeechKITT/0.3.0/themes/flat.css');
SpeechKITT.vroom();
}
</script>
API Docs
For details on all available methods, options and more details, check out the API documentation.
Author
Tal Ater: @TalAter
License
Licensed under MIT.