I'm using a simple Speech to text detection with webkitSpeechRecognition
.
This code works great on Windows Desktop.
But - on Android Chrome browser - When starting detection, the microphone on the Android status bar shows only for 1 or 2 seconds. If there is no voice activity - it turns off and the voice recognition stops. If I do speak very fast after clicking "Start", it stays on.
Any ideas how to make the Android microphone available at all time?
if ('webkitSpeechRecognition' in window) {
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
recognition.onstart = function () {
$("#status").html("Status: Recording...");
recognizing = true;
};
recognition.onerror = function (event) {
alert(event.error);
};
recognition.onend = function() {
recognizing = false;
};
recognition.onresult = function(event) {
var interim_transcript = '';
for (var i = event.resultIndex; i < 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").html(linebreak(final_transcript));
$("#interim_span").html(linebreak(interim_transcript));
};
}
The speech recognition interface lives on the browser's window object as SpeechRecognition in Firefox and as webkitSpeechRecognition in Chrome. Start by setting the recognition interface to SpeechRecognition (regardless of the browser) using: window. SpeechRecognition = window. webkitSpeechRecognition || window.
Web Speech API InterfacesRepresents error messages from the recognition service. The event object for the result and nomatch events, and contains all the data associated with an interim or final speech recognition result. The words or patterns of words that we want the recognition service to recognize.
I looked for a solution to this myself as I am trying to build a hands-free interaction with WebVR.
https://codepen.io/bryik/pen/mErOOR?editors=0010 at least only beeps once, but after a bit of testing I noticed, that the 'beep' for recognition triggers again on every click/tap.
An older resource gave me good hope, that annyang (https://github.com/TalAter/annyang) might work:
https://github.com/cvan/webvr-holodeck/issues/22 But here I guess it's also only calling
recognition.onend = function() {
console.info("voice recognition ended, restarting...");
recognition.start();
}
in the recognition.onend callback. So on android chrome you might encounter recognition beeps every other second...
In the end, MDN doesn't really state if it's possible to have continuous recognition on android chrome (https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition), but every example I looked at didn't quite offer continuous mode on android (at least on CyanogenMod Lollipop)
// edit if you have a look at https://www.microsoft.com/cognitive-services/en-us/speech-api , they somehow manage to have continuous recognition but I can't find anything in their source code...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With