Closed justinhessdev closed 7 years ago
I've made some changes in #2 that should alleviate these issues. Of most relevance to you will be the new startListening
and abortListening
callbacks. The Web Speech API wrapper should be more resilient against re-renders now too.
Let me know if upgrading to 1.0.3 improves things for you!
@JamesBrill
So far this is working beautifully. Thanks so much for taking the time to improve the package. I will let you know if I notice any other issues.
Everything looks great but I'll point out two minor issues I've seen.
The SpeechRecognition still listens when rendered. In my top-level component I call abortListening() and the Web Speech API stops listening. However, it still runs for a half second until componentWillMount gets called. Maybe if by default listening is set to false this will solve that issue. And then on the client side we simply call startListening(). Currently, it seems that the user is always being recorded
The Web Speech API wrapper is more resilient against re-renders now
. However if I am "listening" and I unmount the component I get this warning:
Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the SpeechRecognition component.
Ah, I was hoping it wouldn't get a chance to record anything in that short space of time. My reason for having it on by default was because I figured most people would want a "plug and play" component that didn't require any initialisation. However, I see the need for your use case to be supported. I'm going to look into making the default state configurable.
This shouldn't be hard to fix - I'll try to deal with this as well.
Thanks so much. Making default state configurable is really helpful. I owe you one.
Thanks again
Looking forward to the next release
See #3 for how to set the API to off by default in 1.0.4.
Should also be resolved by those changes.
THANKS!
Working great
If I wrap SpeechRecognitionContainer in a top level component the app is always listening even when I don't want it to -- if I talk the transcript prop gets updated to what I am saying. I want it to start recognizing speech when I click the recording button, not all the time. (The red recording icon always shows in the tab bar. I only want it to show whenI click the recording button).
I tried using this.props.recognition.abort() and this.props.recognition.stop() to try and stop the recognition but nothing works.
Is it possible to choose when I want to start and stop speech recognition?
In addition - the speech recognition does not work when the SpeechRecognitionContainer and the component it wraps gets unmounted and then remounted.
Any suggestions?