使用 GDK 在 Google Glass 上启动应用程序时,是否可以嵌套语音触发器?例如,不仅仅是说“好的,玻璃”->“它的功率水平是多少?” 我想让应用程序提供一个选项。例如“好的,玻璃”->“它的功率等级是多少?” ->“超过 9000”或“低于 9000”。任何帮助都会很棒!
问问题
1958 次
2 回答
13
如果您在 Glass 上安装了多个具有相同语音触发意图过滤器的活动/服务,则当您说出该语音触发器时,它们的所有名称(基于或标签中的android:label
属性)将出现在消歧“子菜单”中。<activity>
<service>
AndroidManifest.xml
例如(假设res/xml/play_a_game_trigger.xml
代表字符串"play a game"的语音触发器):
<activity android:label="Tennis">
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data android:name="com.google.android.glass.VoiceTrigger"
android:resource="@xml/play_a_game_trigger" />
</activity>
<activity android:label="Bowling">
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data android:name="com.google.android.glass.VoiceTrigger"
android:resource="@xml/play_a_game_trigger" />
</activity>
会给你一个看起来像的语音菜单流程
ok glass → play a game → Tennis
Bowling
但是请注意,此菜单还包括来自其他使用相同语音触发器的 APK 的活动/服务。
您可以在 GDK 文档的语音输入页面找到更多详细信息。
于 2013-11-21T15:43:30.157 回答
3
正确的方法是在触发器中使用输入标签
<trigger keyword="@string/start_app" >
<input prompt="@string/promt_text" />
</trigger>
这会提示输入并等待更多音频语音。
然后在您的活动中,您可以使用以下方法捕获此文本:
ArrayList<String> text = getIntent().getExtras().getStringArrayList(RecognizerIntent.EXTRA_RESULTS);
于 2013-11-29T10:29:31.020 回答