voice icon indicating copy to clipboard operation
voice copied to clipboard

Not working properly on more than one page

Open sudeepjainn opened this issue 5 years ago • 8 comments

I want a voice search on more than 1 page. but I am not able to connect on more than one page. it's work only one page. If I switch on another page then it works but if I again switch on the 1st page and search something it works for the 2nd page.

can you help me?

sudeepjainn avatar Jun 01 '20 15:06 sudeepjainn

Having the same error, even when I navigate to another screen and start recognizing, it is not recognizing anything. Please help me how to use the voice recognition in multiple screens.

Thanks!

supunsashika avatar Jun 03 '20 17:06 supunsashika

I too am having a similar issue of using the voice on more than one page consistently...alus there any maintainers for this package willing to help? It seems like a ghost town here. Would appreciate anyone with knowledge on this subject to suggest possible solutions

konslyp avatar Jun 08 '20 12:06 konslyp

Hi, I was facing the same issue. Did you try destroying the listener when you were unmounting your component and re-initializing the component on the new page?

uddish avatar Jun 09 '20 05:06 uddish

Hi, I was facing the same issue. Did you try destroying the listener when you were unmounting your component and re-initializing the component on the new page?

Yes, I did. Do you have any other solution?

sudeepjainn avatar Jun 09 '20 12:06 sudeepjainn

I too was in the same situation. The solution I came up with is to use DeviceEventEmitter. In Voice.onSpeechResults() emit the events and the page where you want to use the voice string get it using a listener.

Voice.js Voice.onSpeechResults = (e) => { const tempString = voiceArray.value[0].toLowerCase(); DeviceEventEmitter.emit("voiceCommandEmitter", { voiceCommand: tempString }); };

NextPage.js componentDidMount() { this.voiceCommandListner = DeviceEventEmitter.addListener("voiceCommandEmitter", this.performActionOnCommand.bind(this)); }

performActionOnCommand is the function where I parse the string. Also do not forget to remove the listener in componentWillUnmount

mayurshelar avatar Jul 07 '20 06:07 mayurshelar

I too was in the same situation. The solution I came up with is to use DeviceEventEmitter. In Voice.onSpeechResults() emit the events and the page where you want to use the voice string get it using a listener.

Voice.js Voice.onSpeechResults = (e) => { const tempString = voiceArray.value[0].toLowerCase(); DeviceEventEmitter.emit("voiceCommandEmitter", { voiceCommand: tempString }); };

NextPage.js componentDidMount() { this.voiceCommandListner = DeviceEventEmitter.addListener("voiceCommandEmitter", this.performActionOnCommand.bind(this)); }

performActionOnCommand is the function where I parse the string. Also do not forget to remove the listener in componentWillUnmount

Thanks, it works as of now

voonic avatar Mar 31 '21 12:03 voonic

Try to destroy the current screen listener before moving to the next screen using...

useFocusEffect( useCallback(() => { Voice.onSpeechStart = onSpeechStartHandler; Voice.onSpeechEnd = onSpeechEndHandler; Voice.onSpeechResults = onSpeechResultsHandler; return () => { Voice.destroy().then(Voice.removeAllListeners); }; }, []), );

girraj96 avatar Feb 07 '22 08:02 girraj96

@AngadSethi please help here..

MhtChawlaRutrust avatar Sep 15 '23 10:09 MhtChawlaRutrust