if ("speechSynthesis" in window) {
  // new speech recognition object
  var recognition = new window.SpeechRecognition();

  // This will run when the speech recognition service returns a result
  recognition.onstart = function() {
    console.log("Voice recognition started. Try speaking into the microphone.");
  };
  
  recognition.onresult = function(event) {
    var transcript = event.results[0][0].transcript;
    console.log(transcript);
  };
  
  // start recognition
  recognition.start();
  //   .....
} else {
  console.log("Speech recognition not supported 😢");
  // code to handle error
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.