我正在尝试建立一个像亚历克斯或谷歌主页的应用程序,假设用户说“嘿MyApp",麦克风应该被打开或与按钮相关的功能应该被自动调用
我已经尝试过API.ai和Ionic TTS插件,但在Ionic中找不到任何可以使用语音命令启用原生功能的插件。
发布于 2019-05-25 17:07:40
是的,您可以使用离子语音识别this完成此操作
ionic cordova plugin add cordova-plugin-speechrecognition
npm install @ionic-native/speech-recognition添加它的模块
然后运行
import { SpeechRecognition } from '@ionic-native/speech-recognition/ngx';
constructor(private speechRecognition: SpeechRecognition) { }
...
// Check feature available
this.speechRecognition.isRecognitionAvailable()
.then((available: boolean) => console.log(available))
// Start the recognition process
this.speechRecognition.startListening(options)
.subscribe(
(matches: string[]) => console.log(matches),
(onerror) => console.log('error:', onerror)
)
// Stop the recognition process (iOS only)
this.speechRecognition.stopListening()
// Get the list of supported languages
this.speechRecognition.getSupportedLanguages()
.then(
(languages: string[]) => console.log(languages),
(error) => console.log(error)
)
// Check permission
this.speechRecognition.hasPermission()
.then((hasPermission: boolean) => console.log(hasPermission))
// Request permissions
this.speechRecognition.requestPermission()
.then(
() => console.log('Granted'),
() => console.log('Denied')
)发布于 2020-07-07 17:44:05
在构造函数中调用语音识别函数,构建并安装应用程序。
然后说确定谷歌打开(你的应用程序名称)谷歌助手打开你的应用程序和语音识别小说将自动触发。
https://stackoverflow.com/questions/56303242
复制相似问题