I am working on a project and I need to translate speech into text I used Expo and React-native-voice.
\*\*[Unhandled promise rejection: TypeError: null is not an object (evaluating 'Voice.onSpeechStart = null')]
- node\_modules\react-native-voice\src\index.js:23:10 in removeAllListeners
- node\_modules\promise\setimmediate\core.js:37:14 in tryCallOne
- ... 9 more stack frames

```js
import React from "react";
import { StyleSheet, Text, View, TouchableOpacity } from "react-native";
import Voice from "react-native-voice";
import * as Permissions from "expo-permissions";

export default class App extends React.Component {
  constructor() {
    super();
    this.state = {
      results: [],
    };
    Voice.onSpeechStart = this.onSpeechStart;
    Voice.onSpeechRecognized = this.onSpeechRecognized;
    Voice.onSpeechEnd = this.onSpeechEnd;
    Voice.onSpeechError = this.onSpeechError;
    Voice.onSpeechResults = this.onSpeechResults;
    Voice.onSpeechPartialResults = this.onSpeechPartialResults;
    Voice.onSpeechVolumeChanged = this.onSpeechVolumeChanged;
  }
  async componentDidMount() {
    const {status} = await Permissions.askAsync(
      Permissions.AUDIO_RECORDING
    );
  }
  componentWillMount(){
    Voice.destroy().then(Voice.removeAllListeners)
  }

  onSpeechStart = (e)=> {
    console.log('onSpeechStart',e);

  };
  onSpeechRecognized =(e)=>{
    console.log('onSpeechRecognized',e); 
  }
  onSpeechEnd = (e)=>{
    console.log('onSpeechEnd'+e);
  }
  onSpeechError =(e)=>{
    console.log('onSpeechError'); 
  }
  onSpeechResults =  e => {
    console.log('onSpeechResults'+e);
    this.setState({
      results: e.value,
    });
  }
  onSpeechPartialResults = e =>{
    console.log('onSpeechPartialResults' + e.value);
  }
  onSpeechVolumeChanged = e =>{
    console.log('onSpeechVolumeChanged');
  }
  _startRecognizing=async()=>{
    try{
      await Voice.start('en-US')
    } catch(e) {
      console.error(e);
    }
  }
  _stopRecognizing = async()=>{
    try{
      await Voice.stop()
    }catch(e){
      console.error(e);

    }
  }

  render() {
    return (
      <View style={styles.container}>
        <TouchableOpacity
          onPress={this._startRecognizing}
          style={{
            backgroundColor: "green",
            height: 40,
            width: 100,
            marginBottom: 10,
          }}
        >
          <Text style={{ 
            fontSize: 20, 
            alignSelf: "center" 
            }}>
              Starts
              </Text>
        </TouchableOpacity>
        <TouchableOpacity
          onPress={this._stopRecognizing}
          style={{ 
            backgroundColor: "red", 
            height: 40, 
            width: 100 
          }}
        >
          <Text style={{ 
            fontSize: 20, 
            alignSelf: "center" 
            }}>
              Stop
              </Text>
        </TouchableOpacity>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});
```

from framework internals\*\*