我正在尝试使用react-native-voice包。在我的项目按钮按下时,我调用了Voice.start('en-US')方法。但它显示了以下错误,
Possible Unhandled Promise Rejection(id: 0):
TypeError: null is not an object (evaluating 'Voice.startSpeech')我已经自动和手动链接了包。但它并没有起作用
附注:我使用expo弹出将项目从expo管理的工作流程中弹出
发布于 2020-12-17 21:16:01
正如您在documentation中看到的,它们在构造函数中具有初始化语音
尝试此
constructor(props) {
Voice.onSpeechStart = this.onSpeechStartHandler.bind(this);
Voice.onSpeechEnd = this.onSpeechEndHandler.bind(this);
Voice.onSpeechResults = this.onSpeechResultsHandler.bind(this);
}
onSpeechStartHandler = () => {}
onSpeechEndHandler = () => {}
onSpeechResultsHandler = () => {}
onStartButtonPress(e){
Voice.start('en-US');
}还要检查权限
https://stackoverflow.com/questions/65338423
复制相似问题