"Test" 启动应用程序。但是我可以使用“ok glass”在我的应用程序中调用菜单。菜单可以正确显示所有 -6ren">
gpt4 book ai didi

java - Google Glass 未列出的上下文语音命令无法正常工作

转载 作者:行者123 更新时间:2023-11-30 11:04:55 25 4
gpt4 key购买 nike

我无法识别未列出的语音命令。我无法像我期望的那样使用语音命令 "ok glass" -> "Test" 启动应用程序。但是我可以使用“ok glass”在我的应用程序中调用菜单。菜单可以正确显示所有 3 个菜单项,但是说 "rotate""free rotate""stop rotate" 不会影响任何事情。我认为未列出的命令的识别有问题,但我不明白。有什么建议么?我也想知道从菜单项到语音触发器的连接是如何发生的,因为菜单项只知道String.xml的字符串?使用触摸条控制菜单效果很好。

list .xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.blah.stl3dviewer" >
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission
android:name="com.google.android.glass.permission.DEVELOPMENT" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.DeviceDefault" >
<activity
android:name=".STLViewportActivity"
android:icon="@drawable/ic_glass_logo"
android:label="@string/app_name" >
<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/voice_trigger" />

</activity>
</application>
</manifest>

菜单.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/rotate_menu_item"
android:title="@string/glass_rotate_trigger"
/>
<item
android:id="@+id/freerotate_menu_item"
android:title="@string/glass_freerotate_trigger"
/>
<item
android:id="@+id/stoprotate_menu_item"
android:title="@string/glass_stoprotate_trigger"
/>
</menu>

字符串.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Test</string>
<string name="title_activity_stlviewport">STL Viewport</string>
<string name="glass_rotate_trigger">Rotate</string>
<string name="glass_stoprotate_trigger">Stop Rotate</string>
<string name="glass_freerotate_trigger">Free Rotate</string>
</resources>

rotate_voice_trigger.xml

<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="@string/glass_rotate_trigger" />

freerotate_voice_trigger.xml

<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="@string/glass_freerotate_trigger" />

stoprotate_voice_trigger.xml

<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="@string/glass_stoprotate_trigger" />

语音触发器.xml

<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="@string/app_name" />

STLViewportActivity.java(只是重要内容的摘录)

public class STLViewportActivity extends Activity {

@Override
protected void onCreate(Bundle bundle) {
//...
getWindow().requestFeature(WindowUtils.FEATURE_VOICE_COMMANDS);
//...
}
@Override
public boolean onCreatePanelMenu(int featureId, Menu menu) {
if (featureId == WindowUtils.FEATURE_VOICE_COMMANDS
|| featureId == Window.FEATURE_OPTIONS_PANEL) {
getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
return super.onCreatePanelMenu(featureId, menu);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
return true;
}

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
if (featureId == WindowUtils.FEATURE_VOICE_COMMANDS
|| featureId == Window.FEATURE_OPTIONS_PANEL) {
switch (item.getItemId()) {
case R.id.rotate_menu_item:
openglViewport.getRenderer().setAutoRotate();
break;
case R.id.stoprotate_menu_item:
openglViewport.getRenderer().setNoRotate();
break;
case R.id.freerotate_menu_item:
openglViewport.getRenderer().setFreeRotate();
break;
default:
return true;
}
return true;
}
return super.onMenuItemSelected(featureId, item);
}
}

最佳答案

我尝试了一些语音命令,这是我的发现:

  1. “测试”似乎不起作用。另一方面,首字母小写的“test”确实有效。这似乎只影响某些词,因为我已经能够成功地使用“下一步”作为触发器。
  2. 将字符串资源“Stop Rotate”更改为“stop_rotate”有效。

关于java - Google Glass 未列出的上下文语音命令无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29841850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com