Skip to content

Instantly share code, notes, and snippets.

@crsrusl
Created August 11, 2017 13:26
Show Gist options
  • Save crsrusl/4bbe737676bd71bee4202bbab85854ad to your computer and use it in GitHub Desktop.
Save crsrusl/4bbe737676bd71bee4202bbab85854ad to your computer and use it in GitHub Desktop.
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
recognition.lang = 'en-US';
recognition.interimResults = false;
recognition.addEventListener('result', (e) => {
let last = e.results.length - 1;
let text = e.results[last][0].transcript;
console.log('Confidence: ' + e.results[0][0].confidence);
console.log(text);
});
recognition.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment