简体   繁体   English

在语音命令上启动应用(android)

[英]Launch app on voice command (android)

I need an example of how I could launch my app on a voice command (trigger word). 我需要一个示例,说明如何通过语音命令(触发词)启动我的应用程序。 So some sort of a service running in the background listening to everything and if the word matches a set textual value (I guess this can be done through Voice Recognition), app will open. 因此,某种在后台运行的服务会监听所有内容,如果单词与设置的文本值匹配(我想这可以通过语音识别来完成),则应用会打开。 I know this is possible, but I've no clue where to start... 我知道这是可能的,但是我不知道从哪里开始...

I see other apps are able to establish this. 我看到其他应用程序也可以确定这一点。 I've close to 1 million users and this is one of the most often requested features. 我的用户接近100万,这是最常被要求的功能之一。

To do this you have to run Android speech recognition as a service instead of as an activity. 为此,您必须将Android语音识别作为服务而非活动来运行。 Then have your service listen for the key word or phrase. 然后让您的服务收听关键词或短语。

Check out this git for example code on how to run Android speech recognition as a service: 查看此git,获取有关如何将Android语音识别作为服务运行的示例代码:

https://github.com/gast-lib/gast-lib/ https://github.com/gast-lib/gast-lib/

Google刚刚从android M引入了一个新的语音交互API

On Android 6 and later, you can just say "Ok Google" or click on the microphone icon, then say "launch YourAppName", and your app will be launched. 在Android 6及更高版本上,您只需说“ Ok Google”或单击麦克风图标,然后说“启动YourAppName”,即可启动您的应用。

If Google voice search cannot recognize your app's name, try to spell it out. 如果Google语音搜索无法识别您的应用名称,请尝试将其拼写清楚。

To turn on "Ok Google" voice search: https://support.google.com/websearch/answer/2940021?hl=en 要打开“ Ok Google”语音搜索: https : //support.google.com/websearch/answer/2940021?hl=zh_CN

Hope that helps! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM