Made a quick library (https://github.com/newshorts/WebSpeechJS) last week that’s working alright for me. Thinking of making it an actual project on github. Just wanted to post a little blurb about it here, before I add documentation and make it a real thing.
It’s called WebSpeechJS. Basically, it just makes it easy to loop the web speech API return (primitive and final) text and call it into a callback.
Use it like this:
[pastacode lang=”markup” message=”” highlight=”” provider=”manual”]
<!-- include the js file -->
<script src="path/to/js/webspeech.js"></script>
<script>
// when the window loads call the script
var options = {
startButton: $('.start'),
stopButton: $('.stop'),
tmpOutput: $('.tmp'),
finalOutput: $('.final'),
onResult: handleWebSpeechResult
};
var ws = new WebSpeech($, options);
// start the processes
ws.init();
</script>
<!-- then in your page template, include necessary the elements -->
<p class="tmp"></p>
<p class="final"></p>
<button class="start">Start</button>
<button class="stop">Stop</button>
[/pastacode]
That’s it for now, easy peasy.