android - 是否可以在本机反应中收听特定单词?
问题描述
我正在使用 React native 构建一个 android 应用程序。
https://github.com/react-native-community/voice这个包可以很好地捕捉语音。但我希望设备始终监听并在说出特定单词后触发事件(如“Hello myapp!”)。
我试过 https://github.com/spokestack/react-native-spokestack
但它不起作用。
任何人都可以帮助我吗?
解决方案
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它会对您有很大帮助。
推荐阅读
- c# - 如何在 MQL4 中修复“未解决的导入调用:在 y.dll 中找不到 x()”
- javascript - JavaScript:如何对嵌套数组进行分组
- sql-server - 在 Microsoft SQL Server Management Studio 中找不到数据库实例
- ruby-on-rails - Ruby on Rails 中的活动记录
- java - 如何更改非 sp 比例的字体大小?
- python - 如何创建 get_cartesian 函数
- oracle - 如何在所述对象的表中执行对象的过程?
- java - Karaf OSGi 配置抛出 ResolutionException: Unable to resolve root: missing requirements [root] osgi.identity;
- regex - 如何分解Angular7中的验证检查?
- javascript - react中获取springboot api的返回值