我正在开发一个将Google智能助理与现有Android应用集成的项目.要求很简单.假设我的应用程序名为TestApp,我希望它只是更改应用程序主页的背景颜色,我希望能够说," 嘿Google,在TestApp上将背景更改为黑色 ".我获得了ActionSDK的链接,但是看一下,我发现它只是一个独立的应用程序,它扩展了Google智能助理,与android本身无关.
我发现的最接近的API就是语音交互.这与我需要做的非常相似,但它只允许预设的语音触发,例如" 打电话给这个人...... "或" 设置闹钟...... ",但是不能像我一样" 改变背景... "例.根据此链接,不允许自定义语音操作.
所以我的问题是,是否可以直接与我的应用程序进行交互并让它完成一项非常简单的任务?
谢谢
android google-voice-actions google-assistant-sdk dialogflow-es
在语音交互API的Google CodeLabs示例中,使用以下intent过滤器定义了一个活动(请参阅步骤6):
<intent-filter>
<action android:name="android.media.action.STILL_IMAGE_CAMERA" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
当使用"OK Google,采取自拍"语音命令时,会使用该android.intent.category.VOICE
类别触发意图.这在LogCat中显示为:
02-26 15:32:42.423 779-6923/? I/ActivityManager: START u0 {act=android.media.action.STILL_IMAGE_CAMERA cat=[android.intent.category.VOICE] flg=0x18000000 pkg=com.example.android.voicecamera cmp=com.example.android.voicecamera/.TakePictureActivity (has extras)} from uid 10027 on display 0
Run Code Online (Sandbox Code Playgroud)
在我自己的应用程序中,我已将以下intent过滤器添加到我的语音搜索活动中:
<intent-filter>
<action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
但是,如果我提供"确定Google,在[我的应用]上搜索计算机",则语音类别不会添加到意图中:
02-26 16:17:26.722 779-14786/? I/ActivityManager: START u0 {act=com.google.android.gms.actions.SEARCH_ACTION pkg=com.my.pkg cmp=com.my.pkg/.activity.VoiceSearchActivity (has extras)} from uid 10027 on display 0
Run Code Online (Sandbox Code Playgroud)
因为此类别未在Intent中正确设置,Activity.isVoiceInteraction()
并且Activity.isVoiceInteractionRoot()
都返回false
.
任何人都可以解释为什么会发生这种情况?
谢谢!
当我使用谷歌语音搜索时,我可以说"发送文本",谷歌将启动我的短信程序.
我可以说"听",谷歌将启动我的默认音乐应用程序.
我的应用程序是否可以注册它自己的"特殊短语",例如:"MyApp DoSomething"然后谷歌启动MyApp并将"DoSomething"作为我可以捕获的参数类型并执行某些操作?
为了更清楚一点 - 我知道用户可以启动MyApp,然后我可以提供启动语音输入的操作,但我希望谷歌语音搜索应用程序能够在确定时启动我的应用程序说出关键短语.
有关语音操作的Google Developer视频声明可以实施自定义语音操作.给出的例子是:
Ok Google, Shazam this song
Run Code Online (Sandbox Code Playgroud)
显然,这不是系统语音操作之一(拍照,设置闹钟等).视频提供的链接指向" 自定义语音操作"页面,其中指出:
For example, developers have implemented commands like "scan my receipt on Walmart"
or "watch trailer for Inception on Flixster."
Run Code Online (Sandbox Code Playgroud)
但是,似乎没有任何关于如何实现自定义语音操作的解释,并且该页面含糊地指出:
Note: We are not accepting requests for Custom Voice Actions.
Stay tuned to Voice Actions - Google Developers and +GoogleDevelopers for product updates.
Run Code Online (Sandbox Code Playgroud)
这是否意味着根本不可能进行自定义语音操作 - 或者可能需要Google特别批准?
我想实现一个自定义的语音操作,所以我可以说一个自定义的短语,例如Ok Google, Foo Bar
我自己的活动会选择它.这可能吗?
编辑:必须在应用程序尚未运行时执行 - 只是为了澄清.
我想构建一个支持Google Assistant和Siri的应用程序。
如何在Flutter中实现这一目标?
我知道现有的语音支持,
但不支持来回语音操作...
谢谢!
siri google-voice-actions flutter sirikit google-assistant-sdk
内容:
我正在尝试将Google语音操作集成到我的应用中。我已经看过并理解了(或至少是我的想法)google codelabs-io2015示例,在此示例中,如果您不修改代码,一切都会按预期工作。当您尝试使此示例适应实际用例时,问题就开始了。
问题:
所以,我的问题是我正在尝试实施搜索语音操作,但是Activity#isVoiceInteraction始终为false。我最终不了解该活动何时以及为何(以及何时未链接)到语音交互器。
研究:
查看Activity,Activity#isVoiceInteraction和Activity#getVoiceInteractor API级别23的源代码,发现以下内容:
/**
* Check whether this activity is running as part of a voice interaction with the user.
* If true, it should perform its interaction with the user through the
* {@link VoiceInteractor} returned by {@link #getVoiceInteractor}.
*/
public boolean isVoiceInteraction() {
return mVoiceInteractor != null;
}
Run Code Online (Sandbox Code Playgroud)
,
/**
* Retrieve …
Run Code Online (Sandbox Code Playgroud) android google-voice-search google-voice-actions voice-interaction