Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuously listening #99

Open
oncode opened this issue Aug 20, 2021 · 0 comments
Open

Continuously listening #99

oncode opened this issue Aug 20, 2021 · 0 comments

Comments

@oncode
Copy link

oncode commented Aug 20, 2021

The continuous param doesn't work properly in Chrome desktop or for Android. It stops when no-speech was detected after usually 3-4 seconds. I think this is done to reduce the traffic, since they transfer the audio to the Google servers to analyse them.

Some implementations just restart the recognition by calling the start method in the onend event as a workaround. This works for desktop, but on Android devices you'll will always hear a connect/disconnect sound, which is rather annoying.

It would be nice to enable the microphone continuously, but (re)start the main processing only when certain keywords/phrase have been detected locally without network connection, like the 'Hey Google' phrase for the voice assistant. Something like:

const recognition = new SpeechRecognition();

// continuously enable microphone to listen to the user
recognition.continuous = true;
// phrase to start the main processing
recognition.startphrase = 'Hey Web';

recognition.start();
recognition.onprocessstart = function() { console.log('main processing has started'); }
recognition.onprocessend = function() { console.log('main processing has ended'); }

// will only be called when startphrase has been said
recognition.onresult = function() { ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant