Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
If you're deploying Dragon Medical Server at your site (and not hosted by Nuance), make sure to configure Dragon Medical SpeechKit for on-premises deployment before speech-enabling your app.
Prerequisites
You've created one or more activities and the session has been initialized.
Procedure
For each activity to be speech-enabled, do the following:
Add the following view declaration to the XML layout file of the activity (/res/layout/myactivity.xml), as the root view:
<com.nuance.speechanywhere.VuiController xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/vuicontroller">Make sure that the
android:idis unique for every VuiController instance.Close the VuiController declaration in the appropriate place with the tag:
</com.nuance.speechanywhere.VuiController>
Your Android app is now capable of speech recognition.
Important information
The VuiController implements the ViewGroup interface, which means that it can contain your activity's complete view hierarchy. Only the views wrapped by the VuiController XML parent node will be speech-enabled. You should add the VuiController declaration to the top level (following the <?xml> tag), as the root view. The original view hierarchy of your activity will be present (and unchanged) as a child of the VuiController view.
All speech-enabled controls must have a unique ID; the android:id field must be present in their XML declaration. If you add the control dynamically, call the setId() method to assign an ID. Controls that don't have a unique ID will be excluded from speech recognition.
For sample code of the layout XML file, see the sample VuiController integration.
Text controls which aren't editable aren't speech-enabled by default, but they can be speech-enabled by calling enableView with a true argument on the VuiController. For more information, see: Excluding text controls from speech recognition.
Optional parameters
If you have a separate recording button in addition to Dragon Medical SpeechKit's speech bar, you must connect a button press event (triggered by a button control or a dedicated hardware button) to the startRecording() and stopRecording() methods on your Session instance to enable the user to start and stop recording.
Fragments
Dragon Medical SpeechKit supports multiple fragments in one activity. To ensure that all fragments in an activity are speech-enabled automatically, follow the procedure above and place the VuiController at the root of your activity's hierarchy.
Setting VUI concept names, enabling/disabling named fields and dynamically modifying the set of speech-enabled views are operations on the VuiController instance. Fragments encapsulate the view hierarchy and its related functionality; you can design fragments so that they also encapsulate all speech recognition-related logic.
It's good practice to pass a VuiController instance reference to all fragments in the speech-enabled activity. The fragments can use this reference to perform all necessary operations on the VuiController. This means that the internal view hierarchy and functionality of the fragments are fully encapsulated and invisible to the enclosing activity.
For an example of a speech-enabled activity with multiple fragments, see the fragment sample app: samples/src/DM_SpeechKitFragmentSample.
Touch event handling and gesture recognition
The VuiController is sensitive to touch events and performs gesture recognition. To ensure that it doesn't interfere with your app's own gesture recognition, follow these guidelines:
If one of the views in your view hierarchy handles touch events and gestures, adding the VuiController to the root of the view hierarchy won't have an effect on your gesture recognition.
If your activity handles touch events and gestures, use the
dispatchTouchEventcallback to capture touch events. ThedispatchTouchEventcallback method is invoked for all events before they reach the view hierarchy.Make sure not to break the chain of event dispatching and call the superclass implementation of the
dispatchTouchEventcallback method; for example, usereturn super.dispatchTouchEvent();as the last line of code in your overridden method implementation.Don't use the
onTouchEventcallback: This is only invoked for events which aren't handled by any view in the activity's hierarchy. As the VuiController handles touch events, this condition won't be satisfied and theonTouchEventcallback will never be invoked. This is Android application framework behavior by design.