// VoiceHandler.js import React, { Component } from 'react'; import { View, Text, Button } from 'react-native'; import Voice from '@react-native-voice/voice'; class VoiceHandler extends Component { constructor(props) { super(props); this.state = { recognized: '', started: '', results: [], }; Voice.onSpeechStart = this.onSpeechStart.bind(this); Voice.onSpeechRecognized = this.onSpeechRecognized.bind(this); Voice.onSpeechResults = this.onSpeechResults.bind(this); } componentWillUnmount() { Voice.destroy().then(Voice.removeAllListeners); } onSpeechStart(e) { this.setState({ started: '√', }); } onSpeechRecognized(e) { this.setState({ recognized: '√', }); } onSpeechResults(e) { this.setState({ results: e.value, }); } async _startRecognizing(e) { this.setState({ recognized: '', started: '', results: [], }); try { await Voice.start('en-US'); } catch (e) { console.error(e); } } render() { return ( Press the button and start speaking.