So far I have been able to convert about 4-5 words from speech to text using the Webspeech API.
my source looks like this;
var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition
var recognition = new SpeechRecognition();
recognition.lang = 'en-US';
recognition.interimResults = false;
recognition.maxAlternatives = 1;
document.body.onclick = function() {
recognition.start();
}
recognition.onresult = function(event) {
var i = event.results.length-1;
var j = event.results[i].length-1;
var text = event.results[i][j].transcript;
diagnostic.textContent = 'Result received: ' + text + '.';
console.log('Confidence: ' + event.results[i][j].confidence);
}
recognition.onspeechend = function() {
recognition.stop();
}
recognition.onerror = function(event) {
diagnostic.textContent = 'Error occurred in recognition: ' + event.error;
}
So when I say anymore words than 5-6 I get an Error occurred in recognition: network error
.
if I say less words it works fine.
I also tried setting the recognition.continuous
variable for what it's worth it did not work.
is there no way I can convert long speeches to text in browser using a free speech to text API?
if so point me in the direction.
or should I convert recorded audio to text in the backend by sending audio to the backend? if so how to do that?