Web Speech API stops listening after a while without input

I use the web speech API, but as soon as a little time passes (a minute or 2) without any vocal input, it completely stops listening. I know this because he writes my analyzed text to the console with me, but he stops doing this when I say neither a minute nor a minute.

Is there any way to fix this?

+6
source share
2 answers

You can listen to the end event, and then restart recognition in the SpeechRecognition object.

You must use the boolean flag to decide (in the onend event onend ) when to restart recognition (and when not to restart).

You can use other recognition events for this.

eg. Chrome fires the following event handlers when recognition is triggered:

 1. onstart 2. onaudiostart (only if sound / speech is detected) 3. onsoundstart 4. onspeechstart 

If no audio speech is detected, only the first 2 will be triggered, and then, after some timeout, the corresponding end events (in reverse order).

+5
source

The top answer is for solving this specific issue, but in the latest version of Chrome, the user will have to allow recording every time.

0
source

Source: https://habr.com/ru/post/1261881/


All Articles