首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用react-native-voice包

无法使用react-native-voice包
EN

Stack Overflow用户
提问于 2020-12-17 17:59:10
回答 1查看 191关注 0票数 0

我正在尝试使用react-native-voice包。在我的项目按钮按下时,我调用了Voice.start('en-US')方法。但它显示了以下错误,

代码语言:javascript
复制
Possible Unhandled Promise Rejection(id: 0):
TypeError: null is not an object (evaluating 'Voice.startSpeech')

我已经自动和手动链接了包。但它并没有起作用

附注:我使用expo弹出将项目从expo管理的工作流程中弹出

EN

回答 1

Stack Overflow用户

发布于 2020-12-17 21:16:01

正如您在documentation中看到的,它们在构造函数中具有初始化语音

尝试此

代码语言:javascript
复制
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://github.com/react-native-voice/voice#permissions

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65338423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档