微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为多个屏幕反应原生语音

如何解决为多个屏幕反应原生语音

我将 react-native-voice/voice 用于我的语音转文本应用程序。但是 voice search 仅适用于初始屏幕,不适用于任何其他屏幕。下面是我实现的代码。请问有什么线索吗?

class BuyerContainer extends Component {
  constructor(props) {
    super(props);
     // Binding the listeners
     Voice.onSpeechError = this.onSpeechError.bind(this);
     Voice.onSpeechResults = this.onSpeechResults.bind(this);
   }
   // Called when I navigate to other screen
   // Used this because componentwillUnmount does not work for stack navigator
   onNavigation = async routeName => {
    await Voice.destroy().then(Voice.removeAllListeners);
    this.props.navigation.navigate(routeName);
  };
 }
}

我为所有屏幕应用了相同的代码结构。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。