Closed thiagoss closed 3 years ago
Hi @thiagoss Can you please share the following:
react-speech-recognition
that you're usingreact-speech-recognition
Some initial comments:
resetTranscript
will clear the transcript. stopListening
will just turn off the microphone, which prevents any additional transcript from being added; the existing transcript will remain.I also tried calling resetTranscript() after calling stopListening() but that seems to turn on listening again for some reason.
This is surprising and is not something I have seen before. As mentioned above, a code snippet will help me understand your configuration and the behaviour you are seeing.I just got latest master as of today (v3.2.0) and turned the example into the issue by adding my code to it: https://github.com/thiagoss/react-speech-recognition/tree/example-issue-58
It makes sense that stopListening doesn't clear the transcript but I'm still unsure why resetTranscript seems to make it start listening again. I was hoping resetting the transcript wouldn't change current listening state.
Testing on Windows Chrome Version 84.0.4147.135 (Official Build) (64-bit)
Indeed, the reset should not affect the listening state.
Thanks for clarifying that, though I think you may be missing SpeechRecognitionPanel
, which your example references but did not commit. Could you include that as well?
Oh, sorry about that. Just added the file.
I was able to reproduce the bug; thanks for the example. I see there is a race condition between resetTranscript
and stopListening
. I am taking a look at a solution.
I see you also used clearTranscriptOnListen
- note that this only does anything when continuous listening is turned off. This clears the transcript when startListening
is called to restart the microphone for discontinuous listening - this works well for the typical "push to talk" use case.
For clearing the transcript when the user stops speaking during continuous listening, you are actually taking the right approach by listening for new final transcripts and resetting then. I will update this issue as soon as I've published a version that enables this to work as expected.
@thiagoss Give v3.2.1 a try.
It worked! Thanks for the quick fix!
Not sure if this is a problem with this project or the underlying Web API. When using continuous mode it keeps listening as expected, but the transcript text is never cleared, even after issuing stopListening().
I also tried calling resetTranscript() after calling stopListening() but that seems to turn on listening again for some reason.