首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >是否有可能使用Ionic实现类似于"OK Google“的功能

是否有可能使用Ionic实现类似于"OK Google“的功能
EN

Stack Overflow用户
提问于 2019-05-25 16:46:13
回答 2查看 950关注 0票数 0

我正在尝试建立一个像亚历克斯或谷歌主页的应用程序,假设用户说“嘿MyApp",麦克风应该被打开或与按钮相关的功能应该被自动调用

我已经尝试过API.ai和Ionic TTS插件,但在Ionic中找不到任何可以使用语音命令启用原生功能的插件。

EN

回答 2

Stack Overflow用户

发布于 2019-05-25 17:07:40

是的,您可以使用离子语音识别this完成此操作

代码语言:javascript
运行
复制
ionic cordova plugin add cordova-plugin-speechrecognition
npm install @ionic-native/speech-recognition

添加它的模块

然后运行

代码语言:javascript
运行
复制
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')
  )
票数 0
EN

Stack Overflow用户

发布于 2020-07-07 17:44:05

在构造函数中调用语音识别函数,构建并安装应用程序。

然后说确定谷歌打开(你的应用程序名称)谷歌助手打开你的应用程序和语音识别小说将自动触发。

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

https://stackoverflow.com/questions/56303242

复制
相关文章

相似问题

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