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).
source share