Add Speech processing power (Adding voice capabilities)
Voice operations are an important part of the wearable user experience, allowing users to perform actions in a fast, hands-free manner.
Wear offers two types of voice operations:
system-provided (system-provided)
These voice operations are task-based and built into the wear platform.
When the Voice command arrives, the action is filtered in the activity you want to start.
such as "Remember" (take a note) or "remind" (Set an alarm).
application Offers (app-provided)
These voice actions are app-based and are declared in the same way as the start icon. The user says "start" to use these voice actions and an activity that you specify.
Claims system-provided voice operations the Android Wear platform provides some voice intents based on user actions, such as "Remember" or "remind" above.
This allows the user to simply say what they want to do, and the system determines which activity to initiate in response.
When a user issues a voice command, your application can listen and filter on this intent, so that the appropriate application will be started by that voice intent (intent).
If you want to start a background service, display an activity in a way that is visible and then start the service on the activity.
When you want to get rid of this visible hint, make sure to call the finish () function.
For example, for the take a note command, declare the following intent filter (Intent Filter) to initiate an activity called mynoteactivity:
<activity android:name= "Mynoteactivity" >
<intent-filter>
<action android:name= "Android.intent.action.SEND"/>
<category android:name= "Com.google.android.voicesearch.SELF_NOTE"/>
</intent-filter>
</activity>
The following is a list of speech intent (voice intents) supported by the Wear platform:
Declare the voice action provided by the app if none of the above system speech intentions meet your requirements, you can start your app directly with the "Start myactivityname" Voice command.
Registering a "Start" action is similar to registering a startup icon on a mobile app.
To specify the text parameters that follow the Start command, you need to specify a label property for the activity.
For example, the following intent filter will recognize the "start Myrunningapp" voice operation and start the startrunactivity.
<application>
<activity android:name= "startrunactivity" android:label= "Myrunningapp" >
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Get free-form Voice input in order to initiate activity using voice actions, you can also call the system's built-in speech recognition activity (Speech recognizer activity) to get the user's voice input.
This is useful for speech recognition and subsequent processing, such as performing a search or sending a voice message.
In the application, you can use the Action_recognize_speech action to invoke the Startactivityforresult () function,
This initiates the activity and can process the speech recognition results in Onactivityresult ().
by Iefreer