voice
voice copied to clipboard
Not working properly on more than one page
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?
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!
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
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?
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?
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
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
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); }; }, []), );
@AngadSethi please help here..