Web Speech API " Detecting known words"
<p>I'm in the process of developing an app which can detect certain key words. I have been using googles web speech. </p>

<p>I'm able to record the users voice and have it print out, but I want to be able to detect certain words. </p>

<p>I can't seem to find a way of doing this. I've found this question <a href="https://stackoverflow.com/questions/20457632/detecting-known-words-using-the-web-speech-api">Detecting known words using the Web Speech API</a> but the site in the answer it links to, is gone.</p>

<p>Can anyone shed a light on this? any help would be great. Cheers! 
<a href="https://jsfiddle.net/ronoc4/b0ufttzd/" rel="nofollow noreferrer">here is a fiddle</a></p>

<pre><code>  var recognition = new webkitSpeechRecognition(); // google voice recognition start

  recognition.continuous = true; //so that recognition will continue even if the user pauses while speaking


  document.getElementById('startSpeech').addEventListener('click', function() {
   startSpeech();
 });
  document.getElementById('stopRecognizing').addEventListener('click', function() {
      stopRecognizing();
  });


  var startSpeech = function(){

  var lang = ['en-GB', 'United Kingdom'];
  final_transcript = '';
    recognition.lang =  recognition.lang
    recognition.start() //activates the speech recognizer
  }

  var stopRecognizing = function(){
   recognition.stop();//stops the mic from listening
   return;
  }  


 recognition.onresult = function(event) {
 console.log('event', event);
 // This handler concatenates all
 // the results received so far into two strings  final_transcript &amp; interim_transcript

var interim_transcript = '';

for (var i = event.resultIndex; i &lt; event.results.length; ++i) {
  if (event.results[i].isFinal) {
    final_transcript += event.results[i][0].transcript;
  } else {
    interim_transcript += event.results[i][0].transcript;
  }
}
//final_transcript = capitalize(final_transcript);
    final_span.innerHTML = linebreak(final_transcript);
    interim_span.innerHTML = linebreak(interim_transcript);

    // console.log('final_transcript' , typeof final_transcript);
    // console.log('interim_transcript' , interim_transcript);

    if (final_transcript.length &gt; 0) {
        matchingKeyWords(final_transcript);
    }
};

      function linebreak(s) {
    var two_line = /\n\n/g;
    var one_line = /\n/g;
    return s.replace(two_line, '&lt;p&gt;&lt;/p&gt;').replace(one_line, '&lt;br&gt;');
}

function capitalize(s) {
    var first_char = /\S/;
    return s.replace(first_char, function(m) { return m.toUpperCase(); });
}


        var matchingKeyWords = function(conversation){

    var keyWords = ['power', 'tie', 'imaginary' ,'bomb', 'drink', 'underwear', 'chance', 'type', 'historical',
        'society' ,'collect' ,'sugar']

        for (var i = 0; i &lt; keyWords.length; ++i) {
            console.log(conversation[0]);
            if (conversation === keyWords[1]) {
                console.log('hit');
            }
            // console.log('keyWords[i]', keyWords[i]);
        }
}
</code></pre>