HTML5 - speech recognition with Javascript

Oscar Brito



With Google Chrome 25 installed you can use the native Javascript Speech Recognition API on your browser.

The essential steps to make it work are:


var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;


recognition.onresult = function(event) {
var interimtranscript = '';

for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
final
transcript += event.results[i][0].transcript;
} else {
interimtranscript += event.results[i][0].transcript;
}
}
final
transcript = capitalize(finaltranscript);
final
span.innerHTML = linebreak(finaltranscript);
interim
span.innerHTML = linebreak(interim_transcript);
};



LINKS:
https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
http://updates.html5rocks.com/2013/01/Voice-Driven-Web-Apps-Introduction-to-the-Web-Speech-API



Visit www.divhide.com for more informations, contacts and news about Web Development.
See other blog posts at blog.divhide.com.



Divhide purpose is to follow the HTML5 movement and contribute with applications which prove the quality of technology.


Feel free to contact divhide.