Search code examples
javascriptgoogle-chromegoogle-speech-api

Google Speech recognition API stops recording after a few seconds


This is the code to recognize speech, it stops recording in a few seconds. The mic icon from the Title Bar vanishes.

var streaming = new webkitSpeechRecognition();
streaming.lang = 'en-IN';
streaming.continuous = true;
streaming.interimResults = true; 

streaming.onresult = function(event) {
  l_pos = event.results.length - 1 ;
  console.log(event.results[l_pos][0].transcript);
}

streaming.onend = function(event) {
  console.log("1")
  streaming.start();
  console.log("2")
}

streaming.start();

How do I make it record continuously?


Solution

  • if you want to record continuously then you can do one thing. There is an onstop or onend event. in that event you can start it again..