Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot abort speech recogntion #1

Closed
justinhessdev opened this issue Jul 21, 2017 · 7 comments
Closed

cannot abort speech recogntion #1

justinhessdev opened this issue Jul 21, 2017 · 7 comments

Comments

@justinhessdev
Copy link

justinhessdev commented Jul 21, 2017

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?

@JamesBrill
Copy link
Owner

JamesBrill commented Jul 22, 2017

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!

@justinhessdev
Copy link
Author

@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.

@justinhessdev
Copy link
Author

Everything looks great but I'll point out two minor issues I've seen.

  1. 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.

@JamesBrill
Copy link
Owner

  1. 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.

  2. This shouldn't be hard to fix - I'll try to deal with this as well.

@justinhessdev
Copy link
Author

  1. Thanks so much. Making default state configurable is really helpful. I owe you one.

  2. Thanks again

Looking forward to the next release

@JamesBrill
Copy link
Owner

  1. See Configurable default state #3 for how to set the API to off by default in 1.0.4.

  2. Should also be resolved by those changes.

@justinhessdev
Copy link
Author

THANKS!

Working great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants