Speech Recognition with Chrome

There are loads of posts online about Speech Recognition* but we have been having so much fun with it we wanted to highlight how easy it is to use.

*Compatibility is a big issue for any client work as it only really works in Chrome…


// Setup browser Speech Recognition
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
var recognition = new SpeechRecognition();
recognition.interimResults = true;
recognition.lang = 'en';

// Event listener for Speech results
recognition.addEventListener('result', function(event) {

// Add Speech Recognition results to var
var transcript = event.results[0][0].transcript;

// Display results in DOM
document.querySelector('.content').textContent = transcript;

}, false);

// Start speech recognition
recognition.start();

// Event listener to restart speech recognition each time user has stopped talking
recognition.addEventListener('end', recognition.start);

For a full list of setting see: https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s