提问者:小点点

是否可以在react Native中侦听特定的单词?


我正在用React Native构建一个android应用程序。

https://github.com/react-native-community/voice这个软件包可以很好地捕获语音。 但我想让设备一直监听,并在说出一个特定的单词(比如“你好,我的应用程序!”)后触发一个事件。

我试过https://github.com/spokestack/react-native-spokestack

但不管用。

有人能帮我吗?


共1个答案

匿名用户

import Voice from 'react-native-voice';
import React, {Component} from 'react';
 
class VoiceTest extends Component {
  constructor(props) {
    Voice.onSpeechStart = this.onSpeechStartHandler.bind(this);
    Voice.onSpeechEnd = this.onSpeechEndHandler.bind(this);
    Voice.onSpeechResults = this.onSpeechResultsHandler.bind(this);
  }
  onStartButtonPress(e){
    Voice.start('en-US');
  }
  ...
}

也请查看此链接https://www.npmjs.com/package/react-native-voice,它将帮助你很多。