title: How can i compare the ibm watson speech to a specific string?
body: <p>Please guide me how can i compare the speech or transcribe from microphone to a string in if else statement. below code is not going inside the if statement. thank you</p>
  
  <pre><code>var stream = recognizeMic({
      token: token,
      objectMode: false, // send objects instead of text
      extractResults: false, // convert {results: [{alternatives:[...]}], result_index: 0} to {alternatives: [...], index: 0}
      format: false // optional - performs basic formatting on the results such as capitals an periods
  
  });
  stream.setEncoding('utf8');
  stream.on('data', (data) =&gt; {
  
      console.log(data);
      var txt = JSON.stringify(data);
      console.log(txt);
      if (txt === "example") {
          console.log("Success");
          window.open("https://www.example.com")
      }
  });
  stream.on('error', function(err) {
  console.log(err);
  });
  //document.querySelector('#stop').onclick = stream.stop.bind(stream);
  }).catch(function(error) {
      console.log(error);
  });
  }
  </code></pre>