Use the WebSpeach API with events.
Listen to a word or quote and the trigger all the callbacks.
- Support jQuery and NodeJS syntax
- Support RequireJS and Globals
- Use https://github.com/ManRueda/phenomenonJS to manage the events
Speech-flow can be used by code or bootstrapping the DOM.
There is two dist compilations, the first (speech-flow.min.js) it's the minified code , the second (speech-flow.uni.min.js) adds the PhenomenonJS's code inside to avoid to include it in you HTML.
The constructor has this properties:
- lang: Language code.
- ignoreCase: Define if the cases have a meaning when the speech is interpreted.
- ignoreDiacritics: Define if the diacritics characters are replaced with their base when the speech is interpreted.
Using code you need to create a speech-flow, attach the words or quotes with a callback and start listening.
speak = new SpeechFlow({
lang: "en-US",
ignoreCase: true,
ignoreDiacritics: true
});
speak.on('my quote', function(){
});
speak.start();Using the bootstrap function you only need to add the speech-flow attribute to an element with this structure as value word or quote:function to execute.
The bootstrap method receive an object with this options.
- autoStart: Define if speech-flow starts to listen automatically.
<button id="btn1" speech-flow="hello:myFunction">Button 1</button>speak = new SpeechFlow({
lang: "en-US",
ignoreCase: true,
ignoreDiacritics: true
});
function myFunction(){
console.log('this function is triggered by the voice');
console.log(this);
}
speak.bootstrap({
autoStart: true
});