I'm using the web speech API but once a bit of time passes by (a minute or 2) without any vocal input, it stops listening entirely. I know this because I have it log its parsed text to the console, however, it stops doing this when I do not talk for a minute or two.
Is there any way to fix this?
You can listen to the
end
event and then restart the recognition on theSpeechRecognition
object.You should use a boolean flag for deciding (in the
onend
event handler), when to restart the recognition (and when not to restart).You could use the other recognition-related events for this.
E.g. Chrome triggers the following event handlers when recognition is started:
If no sound speech is detected, only the first 2 will be triggered, and then, after some timeout, the corresponding
end
events (in reverse order).