- Print
- DarkLight
Using XML to Define Vocabulary
You can define custom speech commands and control the placement the speech hint UI overlay bubbles in your application XML without using the speech SDK directly.
While this mechanism does not give the same level of control as using the Vuzix Speech SDK, it is a very simple mechanism to customize the speech behavior whenever your code runs on a Vuzix device without negatively affecting your application on non-Vuzix devices.
Changing the bubble location
Sometimes the default bubble location obstructs other content on the user interface. This can be easily solved by specifying an explicit bubble location.
vuzix_bubble_location
This tag defines one of nine predefined locations, or an x,y offset for the overlay.
The values can be:
"TOP_START"
"TOP_CENTER"
"TOP_END"
"CENTER_START"
"CENTER_CENTER"
"CENTER_END"
"BOTTOM_START"
"BOTTOM_CENTER"
"BOTTOM_END"
“x,y“
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/test_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="vuzix_bubble_location:BOTTOM_START"
android:contentDescription="vuzix_bubble_location:10,5">
</RelativeLayout>
Using the text instead of the number
To make a richer user experience, the localized text of the button can be used as the speech phrase instead of a numeric value. This is useful when the button has a text label that is relatively easy to speak, such as “continue”.
vuzix_use_text
This tag changes the overlay behavior so that instead of a numeric index the text of the UI element is shown. (NOTE that vuzix_use_text does not take an argument.)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/test_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test Button"
android:contentDescription="vuzix_use_text">
</RelativeLayout>
Custom phrases
You can specify a custom phrase in the bubbles for each of your UI elements instead of using the system-generated numbers or the text attributes of your items. This gives the greatest control for customizing the phases without using the Vuzix Speech SDK.
vuzix_voice_command
This tag changes the overlay behavior so that instead of a numeric index the given text is shown.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/test_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="vuzix_voice_command:foobar">
</RelativeLayout>