Closed EggTronic closed 4 years ago
Another possible feature is about this API
SpeechRecognition.startListening({ continuous: true })
Would be nice if we can set the time threshold about when to continue listening
SpeechRecognition.startListening({ continuous: true, threshold: 2000 }) // if there is no further voice input within 2 seconds, it stops listening
I somehow implemented using the following way
Just to confirm that I understand what you're suggesting:
A simpler approach that might fit your needs is to instead focus on the finalTranscript
(the difference between this and the interim transcript is explained here). This is only updated when the Speech Recognition API is confident that the user has finished saying something. So you could have an Effect Hook that listens for changes to finalTranscript
and validates it against your command list. Such a hook would represent "do something when the user stops speaking", which is similar to your Feature 1, just without the time element.
If you really need a time-based callback (i.e. something happens exactly X seconds after speech finishes), then I'm open to considering that, though I'd like to understand the use case first. If the use case is quite specific to your application, I may instead add it to a Recipes
section in the documentation.
Oh yes, I didn't realize the usage of finalTranscript
before, it works for the Feature 1.
I also agree that the time-based callback is unlikely to be a necessary feature.
Thank you.
For instance, if there is no further voice input within 2 seconds, the recognition starts to check if it is a valid command or not, if not then a special callback for non-valid commands is called. Within this callback, the user may be able to resetTranscript or display some text feedback.