# Print output for @column tags ?>
public
class
VuzixSpeechClient
extends Object
java.lang.Object | |
↳ | com.vuzix.sdk.speechrecognitionservice.VuzixSpeechClient |
The Vuzix Speech Recognizer is a fully embedded, fast, phrase-matching recognition system designed to interpret and respond to voice commands. A platform base vocabulary is available to all apps; it is intended to facilitate default navigation and selection without direction from the client app. That is, a client app can benefit from navigation provided by a base vocabulary with no setup or explicit awareness of the speech recognizer. This capability is implemented by mapping phrases to Android key events (android.view.KeyEvent).
For many applications, it is desirable to implement a custom vocabulary which performs application-specific actions when an application-specific phrase is spoken (e.g. to capture a still image when “take a picture” is spoken.) The Vuzix Speech Recognition system provides two mechanisms by which this can be achieved: Android key events as previously described and Android intents.
A custom vocabulary for an activity should be specified in its onCreate() method using a
constructor like:
VuzixSpeechClient sc = new VuzixSpeechClient(this);
This allows the custom vocabulary to be created when the VuzixSpeechClient class is instantiated. The new custom vocabulary initially inherits the platform base vocabulary which is documented on the developer center of www.vuzix.com. You can also view the base vocabulary on your device by saying "Hello Vuzix, speech commands".
The custom vocabulary can then have the inherited phrases removed or replaced if needed, and new phrases added
The phrases associated with navigation generate a keycode when the phrase is spoken. Phrases associated with intents cause the intent to be delivered when the phrase is spoken.
See also:
Nested classes | |
---|---|
enum |
VuzixSpeechClient.SpeechTolerance
Valid values for getSpeechTolerance() and setSpeechTolerance() |
Constants | |
---|---|
String |
ACTION_VOICE_COMMAND
Intent action used to notify SDK clients of certain phrases recognized by the speech engine and certain speech engine states. |
int |
BUILT_IN_ACTION_ASSISTANT
Parameter for |
int |
BUILT_IN_ACTION_ASSIST_ALEXA
Parameter for |
int |
BUILT_IN_ACTION_ASSIST_GOOGLE
Parameter for |
int |
BUILT_IN_ACTION_CLEAR_NOTIFICATIONS
Parameter for |
int |
BUILT_IN_ACTION_COMMAND_LIST
Parameter for |
int |
BUILT_IN_ACTION_FLASHLIGHT_OFF
Parameter for |
int |
BUILT_IN_ACTION_FLASHLIGHT_ON
Parameter for |
int |
BUILT_IN_ACTION_SLEEP
Parameter for |
int |
BUILT_IN_ACTION_SPEECH_SETTINGS
Parameter for |
int |
BUILT_IN_ACTION_START_RECORDING
Parameter for |
int |
BUILT_IN_ACTION_TAKE_PHOTO
Parameter for |
int |
BUILT_IN_ACTION_VIEW_NOTIFICATIONS
Parameter for |
String |
EXTRA_PAUSE_ACCESSIBILITY
String extra sent only to AccessibilityService to request pause/resume |
String |
EXTRA_VOCAB_KB_PHRASES
String extra used only by InputMethodService to provide a phrase. |
String |
EXTRA_VOCAB_KB_SUBSTITUTION
String extra used only by InputMethodService to provide a substitution. |
String |
EXTRA_VOCAB_RELOAD_REQUIRED
Extra sent when an internal change in the speech recognizer requires that client apps reload any custom vocabularies. |
int |
KEY_FREQ_REPEATING
This keyCode may only be a repeating action, such as "scroll left". |
int |
KEY_FREQ_SINGLE_OR_REPEAT
This keyCode may be a single-press action, such as "move left" or a repeating action such as "scroll left". |
int |
KEY_FREQ_SINGLE_PRESS
This keyCode may only be a single-press action, such as "move left". |
String |
PHRASE_STRING_EXTRA
Intent extra used to notify clients of a recognized phrase. |
String |
RECOGNIZER_ACTIVE_BOOL_EXTRA
Intent extra used to notify clients when the speech recognizer becomes active or inactive. |
Public constructors | |
---|---|
VuzixSpeechClient(Activity activity)
Constructs a speech SDK client for an Activity. |
|
VuzixSpeechClient(Fragment fragment)
This constructor is deprecated.
This is only supported by M300 and not recommended. Use |
|
VuzixSpeechClient(InputMethodService service)
Constructs a speech SDK client for an InputMethodService. |
|
VuzixSpeechClient(AccessibilityService service)
Constructs a speech SDK client for an AccessibilityService Using this will install the custom vocabulary for your AccessibilityService. |
Public methods | |
---|---|
boolean
|
CancelRepeatingCharacters()
Stops any characters that are repeating, such as those resulting from "scroll down". |
static
void
|
EnableRecognizer(boolean enabled)
This method is deprecated.
Use |
static
void
|
EnableRecognizer(Context context, boolean enabled)
Enables or disables the Speech Recognition engine programmatically. |
static
void
|
TriggerVoiceAudio()
This method is deprecated.
Use |
static
void
|
TriggerVoiceAudio(boolean triggered)
This method is deprecated.
Use |
static
void
|
TriggerVoiceAudio(Context context, boolean triggered)
Triggers or deactivates the Speech Recognition engine programmatically. |
static
void
|
TriggerVoiceAudio(Context context)
Triggers the Speech Recognition engine programmatically. |
boolean
|
control(String type, String params)
Invokes a named control method with parameters. |
boolean
|
control(String type)
This method invokes a named control method without parameters. |
static
String
|
convertPhraseToReplyFormat(String phrase)
Converts a phrase to the format it will be returned if detected by the engine For certain phrases, the speech engine sends an intent of action ACTION_VOICE_COMMAND along with a PHRASE_STRING_EXTRA containing a representation of the recognized phrase. |
boolean
|
defineIntent(String label, Intent intent)
Define an arbitrary Intent that may be associated with phrases. |
boolean
|
deleteAllPhrases()
Deletes all phrases. |
boolean
|
deleteAllPhrasesExcept(List<String> exceptions)
Deletes all phrases except the list that you wish to keep. |
boolean
|
deleteIntent(String label)
Delete an Intent previously registered by |
boolean
|
deletePhrase(String phrase)
Deletes a single phrase from the current client vocabulary. |
String
|
dump()
Dumps the content of the entire speech recognition phrase map to a String. |
boolean
|
getBluetoothSetting()
Gets the system-wide "Bluetooth input" setting. |
List<String>
|
getBuiltInActionPhrases(int builtInAction)
Gets the phrase associated with a built-in action, such as illuminating the flashlight. |
static
float
|
getEngineVersion()
Query the device for the version of the speech engine backing the SDK calls. |
List<String>
|
getIntentLabels()
Lists all available intent labels as previously defined by calls to |
List<String>
|
getIntentPhrases(String intentLabel)
Gets the phrases associated with a specific intent label. |
List<String>
|
getKeycodePhrases(int keycode, int keyFrequency)
Gets the phrases associated with a key event. |
List<Integer>
|
getMappedKeycodes(int keyFrequency)
Get all keycodes that have an associated phrase in the vocabulary. |
List<String>
|
getPhrases(String substitution)
Get the subset of active phrases matching a specific substitution. |
List<String>
|
getPhrases()
Get the list of active phrases for this client. |
int
|
getRecognizerTimeoutConfig()
Gets the configured speech recognizer timeout value. |
int
|
getRecognizerTimeoutMax()
Gets the maximum value allowed for setRecognizerTimeoutConfig(). |
boolean
|
getSleepEnableSetting()
Gets the system-wide "Listen while asleep" setting. |
VuzixSpeechClient.SpeechTolerance
|
getSpeechTolerance()
Gets the system-wide "Pronunciation tolerance" setting. |
List<String>
|
getStopPhrases()
Gets all stop phrases including pre-defined and those created by calling |
List<String>
|
getStoredVocabularyNames()
Lists all vocabularies previously saved by the current activity. |
String
|
getSubstitution(String phrase)
Get the optional substitution associated with a phrase. |
List<String>
|
getVoiceOffPhrases()
Gets all voice-off phrases including pre-defined and those created by calling |
List<String>
|
getWakeWordPhrases()
Gets all wake-words including pre-defined and those created by calling |
boolean
|
insertIntentPhrase(String phrase, String intentLabel, String params)
Insert a phrase to generate the specified intent upon the phrase being detected, with extra undocumented parameters. |
boolean
|
insertIntentPhrase(String phrase, String intentLabel)
Insert a phrase to generate the specified intent upon the phrase being detected. |
boolean
|
insertKeycodePhrase(String phrase, int keycode, int repeatIntervalMs, String params)
Inserts a phrase to generate a keycode that will be sent repeatedly upon detection, with extra undocumented capabilities. |
boolean
|
insertKeycodePhrase(String phrase, int keycode)
Inserts a phrase to generate a keycode that will be sent upon detection. |
boolean
|
insertKeycodePhrase(String phrase, int keycode, int repeatIntervalMs)
Inserts a phrase to generate a keycode that will be sent repeatedly upon detection. |
boolean
|
insertKeycodePhrase(String phrase, int keycode, String params)
Inserts a phrase to generate keycodes upon detection, with extra undocumented capabilities. |
boolean
|
insertPhrase(String phrase)
This is the most basic way to insert a phrase into the recognizer. |
boolean
|
insertPhrase(String phrase, String substitution)
Inserts a phrase and provides a substitution to make processing easier for the client. |
boolean
|
insertStopPhrase(String phrase)
Insert a phrase to stop any repeating character that may be active. |
boolean
|
insertVoiceOffPhrase(String phrase)
Insert a phrase to deactivate the recognizer, as done by "voice off" in the base vocabulary. |
boolean
|
insertWakeWordPhrase(String phrase)
Insert a phrase to wake the recognizer, as done by "Hello, Vuzix" in the base vocabulary. |
static
boolean
|
isRecognizerEnabled(Context context)
Determines if the speech recognizer is currently enabled in Settings. |
static
boolean
|
isRecognizerInitialized(Context context)
Determines if the speech recognizer has been initialized. |
static
boolean
|
isRecognizerTriggered(Context context)
Determines if the speech recognizer is currently triggered and listening for the full vocabulary. |
boolean
|
removeVocabulary(String name)
Remove and delete the recognizer vocabulary in the vocabulary store represented by "name". |
boolean
|
retrieveVocabulary(String name)
Replace the current activity vocabulary with the vocabulary from the vocabulary store represented by "name". |
void
|
setBluetoothSetting(boolean value)
Sets the system-wide "Bluetooth input" setting. |
boolean
|
setRecognizerTimeoutConfig(int timeoutSecs)
Sets the configured speech recognizer timeout value. |
void
|
setSleepEnableSetting(boolean value)
Sets the system-wide "Listen while asleep" setting. |
void
|
setSpeechTolerance(VuzixSpeechClient.SpeechTolerance value)
Sets the system-wide "Pronunciation tolerance" setting. |
static
void
|
startGlobalSpeechSettingsActivity(Context context)
Open the global system-wide settings screen for the speech commands. |
boolean
|
storeVocabulary(String name)
Save a recognizer vocabulary in the vocabulary store for later use. |
public static final String ACTION_VOICE_COMMAND
Intent action used to notify SDK clients of certain phrases recognized by the speech engine and certain speech engine states. Use this string to register for Intents coming from the Speech Client.
For example, from a class implementing BroadcastHandler: yourActivity.registerReceiver(this, new IntentFilter(VuzixSpeechClient.ACTION_VOICE_COMMAND));
Constant Value: "com.vuzix.action.VOICE_COMMAND"
public static final int BUILT_IN_ACTION_ASSISTANT
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with launching the
currently preferred assistant, such as Google or Alexa.
Constant Value: 10 (0x0000000a)
public static final int BUILT_IN_ACTION_ASSIST_ALEXA
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with launching the
Alexa application.
Constant Value: 11 (0x0000000b)
public static final int BUILT_IN_ACTION_ASSIST_GOOGLE
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with launching the
Google Assistant application.
Constant Value: 12 (0x0000000c)
public static final int BUILT_IN_ACTION_CLEAR_NOTIFICATIONS
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with clearing all
Android notifications.
Constant Value: 7 (0x00000007)
public static final int BUILT_IN_ACTION_COMMAND_LIST
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with opening the help
page that shows the list of all available speech commands.
Constant Value: 2 (0x00000002)
public static final int BUILT_IN_ACTION_FLASHLIGHT_OFF
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with turning off the
flashlight.
Constant Value: 5 (0x00000005)
public static final int BUILT_IN_ACTION_FLASHLIGHT_ON
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with turning on
the flashlight.
Constant Value: 4 (0x00000004)
public static final int BUILT_IN_ACTION_SLEEP
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with causing the system to
go to sleep.
Constant Value: 1 (0x00000001)
public static final int BUILT_IN_ACTION_SPEECH_SETTINGS
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with opening the
system-wide speech settings application.
Constant Value: 3 (0x00000003)
public static final int BUILT_IN_ACTION_START_RECORDING
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with recording a
video.
Constant Value: 8 (0x00000008)
public static final int BUILT_IN_ACTION_TAKE_PHOTO
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with taking a
photograph.
Constant Value: 9 (0x00000009)
public static final int BUILT_IN_ACTION_VIEW_NOTIFICATIONS
Parameter for getBuiltInActionPhrases(int)
to request phrases associated with viewing the system
Android notifications.
Constant Value: 6 (0x00000006)
public static final String EXTRA_PAUSE_ACCESSIBILITY
String extra sent only to AccessibilityService to request pause/resume
Constant Value: "pause_accessibility"
public static final String EXTRA_VOCAB_KB_PHRASES
String extra used only by InputMethodService to provide a phrase.
Constant Value: "kb_phrases"
public static final String EXTRA_VOCAB_KB_SUBSTITUTION
String extra used only by InputMethodService to provide a substitution.
Constant Value: "kb_subst"
public static final String EXTRA_VOCAB_RELOAD_REQUIRED
Extra sent when an internal change in the speech recognizer requires that client apps reload any custom vocabularies.
Constant Value: "vocab_reload_required"
public static final int KEY_FREQ_REPEATING
This keyCode may only be a repeating action, such as "scroll left". Used by
getKeycodePhrases(int, int)
and getMappedKeycodes(int)
Constant Value: 2 (0x00000002)
public static final int KEY_FREQ_SINGLE_OR_REPEAT
This keyCode may be a single-press action, such as "move left" or a repeating action such as
"scroll left". Used by getKeycodePhrases(int, int)
and getMappedKeycodes(int)
Constant Value: 0 (0x00000000)
public static final int KEY_FREQ_SINGLE_PRESS
This keyCode may only be a single-press action, such as "move left". Used by
getKeycodePhrases(int, int)
and getMappedKeycodes(int)
Constant Value: 1 (0x00000001)
public static final String PHRASE_STRING_EXTRA
Intent extra used to notify clients of a recognized phrase.
Clients will receive an intent with this String extra and an action ACTION_VOICE_COMMAND whenever a custom phrase they have inserted is recognized.
Constant Value: "phrase"
public static final String RECOGNIZER_ACTIVE_BOOL_EXTRA
Intent extra used to notify clients when the speech recognizer becomes active or inactive.
Clients will receive an intent with this boolean extra and an action ACTION_VOICE_COMMAND whenever the recognizer is triggered (ie: "Hello Vuzix") and becomes active, or times-out and returns its inactive idle state listening for the wake-up phrase.
When the recognizer begins to listen, the boolean is set true. When the recognizer ceases to listen, the boolean is set false
Constant Value: "active"
public VuzixSpeechClient (Activity activity)
Constructs a speech SDK client for an Activity.
Using this will install the custom vocabulary for your entire Activity. Initially your custom vocabulary will be an exact copy of the system default vocabulary.
Parameters | |
---|---|
activity |
Activity : The Activity in which this custom vocabulary will operate. |
Throws | |
---|---|
RemoteException |
if the speech engine service is not running on the device |
public VuzixSpeechClient (Fragment fragment)
This constructor is deprecated.
This is only supported by M300 and not recommended. Use VuzixSpeechClient(android.app.Activity)
instead.
Constructor from a Fragment. Using this will install the custom vocabulary for a single Fragment within your Activity.
WARNING Not supported by Blade and M400 and not recommended for new development.
Parameters | |
---|---|
fragment |
Fragment : The Fragment in which this custom vocabulary will operate. |
Throws | |
---|---|
RemoteException |
if the speech engine service is not running on the device. |
IllegalArgumentException |
if the device does not support this interface. |
public VuzixSpeechClient (InputMethodService service)
Constructs a speech SDK client for an InputMethodService. Using this will install the custom vocabulary for your InputMethodService.
Parameters | |
---|---|
service |
InputMethodService : The InputMethodService in which this custom vocabulary will operate. |
Throws | |
---|---|
RemoteException |
if the speech engine service is not running on the device. |
public VuzixSpeechClient (AccessibilityService service)
Constructs a speech SDK client for an AccessibilityService Using this will install the custom vocabulary for your AccessibilityService.
Parameters | |
---|---|
service |
AccessibilityService : The AccessibilityService in which this custom vocabulary will operate. |
Throws | |
---|---|
RemoteException |
if the speech engine service is not running on the device. |
public boolean CancelRepeatingCharacters ()
Stops any characters that are repeating, such as those resulting from "scroll down".
Invoking this is similar to the user saying "stop".
Returns | |
---|---|
boolean |
True if the no characters are now repeating. False otherwise. |
public static void EnableRecognizer (boolean enabled)
This method is deprecated.
Use EnableRecognizer(android.content.Context, boolean)
instead.
Enables or disables the Speech Recognition engine programmatically by attempting to determine the Context.
It is the equivalent of turning on or off the "Enable Vuzix Speech Recognition" switch in the global Settings application.
Use the method with the Context parameter if possible; this method is less reliable.
Parameters | |
---|---|
enabled |
boolean : True to enable the recognizer. False to disable it. |
public static void EnableRecognizer (Context context, boolean enabled)
Enables or disables the Speech Recognition engine programmatically.
This is the equivalent of turning on or off the "Enable Vuzix Speech Recognition" switch in the global Settings application.
Note: This is the preferred method invocation, explicitly specifying a valid Context.
Parameters | |
---|---|
context |
Context : The context from which the trigger is being invoked. |
enabled |
boolean : True to enable voice recognition. False to disable. |
public static void TriggerVoiceAudio ()
This method is deprecated.
Use TriggerVoiceAudio(android.content.Context, boolean)
instead with the triggered parameter
set true.
Triggers the Speech Recognition engine programmatically by attempting to determine the context.
Note: Use the method with the Context parameter if possible; this method is less reliable.
public static void TriggerVoiceAudio (boolean triggered)
This method is deprecated.
Use TriggerVoiceAudio(android.content.Context, boolean)
instead.
Triggers or deactivates the Speech Recognition engine programmatically.
It is the equivalent of recognizing the trigger phrase (e.g. "Hello Vuzix") in an audio stream.
Parameters | |
---|---|
triggered |
boolean : True to trigger the recognizer. False to put it to sleep. |
public static void TriggerVoiceAudio (Context context, boolean triggered)
Triggers or deactivates the Speech Recognition engine programmatically.
It is the equivalent of recognizing the trigger phrase (e.g. "Hello Vuzix") in an audio stream.
Note: This is the preferred method invocation, explicitly specifying a valid Context.
Parameters | |
---|---|
context |
Context : The context from which the trigger is being invoked |
triggered |
boolean : True to trigger the recognizer. False to put it to sleep. |
public static void TriggerVoiceAudio (Context context)
Triggers the Speech Recognition engine programmatically.
It is the equivalent of TriggerVoiceAudio(android.content.Context, boolean)
with the "triggered"
parameter set to true.
Parameters | |
---|---|
context |
Context : The context from which the trigger is being invoked |
See also:
public boolean control (String type, String params)
Invokes a named control method with parameters.
This interface is not normally required. All expected 3rd party interfaces have explicit methods to be used in place of this. In limited circumstances Vuzix Technical Support may recommend explicit recommendations for using this. It should not be used otherwise.
Parameters | |
---|---|
type |
String : The text type of the control. Provided by Vuzix technical support in limited
applications. |
params |
String : The text value to set to the control. Provided by Vuzix technical support in
limited applications. |
Returns | |
---|---|
boolean |
True if the control is set. False otherwise. |
public boolean control (String type)
This method invokes a named control method without parameters.
This interface is not normally required. All expected 3rd party interfaces have explicit methods to be used in place of this. In limited circumstances Vuzix Technical Support may recommend explicit recommendations for using this. It should not be used otherwise.
Parameters | |
---|---|
type |
String : The text type of the control. Provided by Vuzix technical support in limited
applications. |
Returns | |
---|---|
boolean |
True if the control is set. False otherwise. |
public static String convertPhraseToReplyFormat (String phrase)
Converts a phrase to the format it will be returned if detected by the engine For certain phrases, the speech engine sends an intent of action ACTION_VOICE_COMMAND along with a PHRASE_STRING_EXTRA containing a representation of the recognized phrase. That representation matches the original phrase with whitespace replaced by underscores. This utility converts requested phrases into the same format. You can compare the output of this method against phrases from the PHRASE_STRING_EXTRA to determine if it was the detected phrase.
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen |
Returns | |
---|---|
String |
String modified to match what is returned by the speech engine |
public boolean defineIntent (String label, Intent intent)
Define an arbitrary Intent that may be associated with phrases.
Note: Intents are sent with sendBroadcastAsUser() from the service. They will not start new activities as would happen from startActivityForResult().
This method must be called prior to calling insertIntentPhrase(java.lang.String, java.lang.String)
For example: Intent focus_intent = new Intent(“com.mycompany.camera.speechrecog”).putExtra("focus", true); sc.defineIntent("cam_focus", focus_intent); sc.insertIntentPhrase("focus image", “cam_focus”);
Here, defineIntent() defines the intent for the vocabulary's later use, assigning it a label (“cam_focus”) by which it will be identified in insertIntentPhrase()
Parameters | |
---|---|
label |
String : An arbitrary label by which this new Intent will be identified during insertIntentPhrase(java.lang.String, java.lang.String) |
intent |
Intent : The Intent your Activity wishes to receive. |
Returns | |
---|---|
boolean |
True if the Intent can be defined. False otherwise. |
Throws | |
---|---|
RemoteException |
if the speech engine service is not running on the device. |
See also:
public boolean deleteAllPhrases ()
Deletes all phrases.
Note: this is primarily used when re-defining a vocabulary. To stop the recognizer from functioning you may use EnableRecognizer(false) instead of deleting the phrases.
Returns | |
---|---|
boolean |
True if all phrases are deleted successfully. |
public boolean deleteAllPhrasesExcept (List<String> exceptions)
Deletes all phrases except the list that you wish to keep.
Parameters | |
---|---|
exceptions |
List : The list of phrases to keep. All other phrases will be deleted. |
Returns | |
---|---|
boolean |
True if all phrases other than the exception list are deleted successfully. |
public boolean deleteIntent (String label)
Delete an Intent previously registered by defineIntent(java.lang.String, android.content.Intent)
.
This method also deletes any phrases that were added with insertIntentPhrase(java.lang.String, java.lang.String)
and are associated with the Intent being removed.
Parameters | |
---|---|
label |
String : - the unique string label provided previously to defineIntent(java.lang.String, android.content.Intent) |
Returns | |
---|---|
boolean |
True if the intent is deleted. False otherwise. |
Throws | |
---|---|
RemoteException |
if the speech engine service is not running on the device |
See also:
public boolean deletePhrase (String phrase)
Deletes a single phrase from the current client vocabulary.
You may delete phrases inherited from the base vocabulary as well as those you have added yourself.
Note that the deletion is in effect only when this activity is running; the base vocabulary which is used outside the context of this activity is not affected.
For Example: sc.deletePhrase("take photo"); or better: sc.deletePhrase( mContext.getString(R.string.voice_cmd_take_photo) );
Parameters | |
---|---|
phrase |
String : The phrase to be deleted from the speech recognition map. |
Returns | |
---|---|
boolean |
True if the phrase is found and deleted. False if the string is not present in the map. |
Throws | |
---|---|
IllegalArgumentException |
if the phrase is not valid. |
public String dump ()
Dumps the content of the entire speech recognition phrase map to a String.
The client is responsible for logging or printing this information
This is used for debugging. It includes inherited entries and custom entries.
See getPhrases()
for a more user-friendly method to query the vocabulary.
Returns | |
---|---|
String |
A single String with a phrase pair per row, separated by carriage returns. |
See also:
public boolean getBluetoothSetting ()
Gets the system-wide "Bluetooth input" setting.
This allows the system to listen to Bluetooth headset audio for speech commands whenever one is connected.
Returns | |
---|---|
boolean |
The value of the headset settings as a boolean |
Throws | |
---|---|
Exception |
public List<String> getBuiltInActionPhrases (int builtInAction)
Gets the phrase associated with a built-in action, such as illuminating the flashlight.
This is useful for creating help messages to instruct users of available voice commands. It may also be used to find unwanted phrases to delete. The advantage of querying the SDK for these phrases is the device may change the phrases in the various supported language when the system is updated. This ensures your application knows the current active phrases.
Note: Not all built-in actions apply to all devices. Unsupported actions will simply return an empty list, so all actions are valid parameters on all devices.
Returns | |
---|---|
List<String> |
List of phrase strings that match the specified built-in action. |
public static float getEngineVersion ()
Query the device for the version of the speech engine backing the SDK calls.
The SDK used at compile-time is often different than the one running on the device.
If the device has a newer SDK than the one against which you compiled, the device has additional capabilities that are inaccessible to your application. You should update your project to pull the latest SDK.
If the device has an older SDK than the one against which you compiled, certain features may be unavailable. You should guard against calling these and handle exceptions properly.
Failure to resolve this method indicates the device is running SDK 1.7 or lower
Returns | |
---|---|
float |
The speech engine version number running on the current hardware. |
public List<String> getIntentLabels ()
Lists all available intent labels as previously defined by calls to defineIntent(java.lang.String, android.content.Intent)
.
Returns | |
---|---|
List<String> |
All labels provided to defineIntent(java.lang.String, android.content.Intent) . |
Throws | |
---|---|
RemoteException |
if the speech engine service is not running on the device |
See also:
public List<String> getIntentPhrases (String intentLabel)
Gets the phrases associated with a specific intent label.
Parameters | |
---|---|
intentLabel |
String : The label matching one previously registered using defineIntent(java.lang.String, android.content.Intent) . |
Returns | |
---|---|
List<String> |
List of phrase strings matching the criteria. |
public List<String> getKeycodePhrases (int keycode, int keyFrequency)
Gets the phrases associated with a key event.
These phrases can be filtered to exclude repeating keys, to only return repeating keys, or to include all.
This is useful for creating help messages to instruct users of possible voice commands and may be used for finding unwanted phrases to delete. The advantage of querying the SDK for these phrases is the device may change the phrases in the various supported language when the system is updated. This ensures your application knows the current active phrases.
For example, to get the "scroll left" phrase, you could use:
phrases = getKeycodePhrase(KEYCODE_DPAD_LEFT, KEY_FREQ_REPEATING);
Parameters | |
---|---|
keycode |
int : The key code as defined in android.view.KeyEvent (ie: KEYCODE_ENTER) |
keyFrequency |
int : May be one of |
Returns | |
---|---|
List<String> |
List of phrase strings matching the criteria. |
public List<Integer> getMappedKeycodes (int keyFrequency)
Get all keycodes that have an associated phrase in the vocabulary.
Parameters | |
---|---|
keyFrequency |
int : May be one of |
Returns | |
---|---|
List<Integer> |
List of key code values (as defined in android.view.KeyEvent) with which there is currently a speech phrase associated. |
public List<String> getPhrases (String substitution)
Get the subset of active phrases matching a specific substitution.
Since multiple phrases may have the same substitution, this provides a way to see what is currently active.
Parameters | |
---|---|
substitution |
String : The substitution as passed to insertPhrase(java.lang.String, java.lang.String) or
null to get all phrases that have no explicit substitution. |
Returns | |
---|---|
List<String> |
List of phrase strings that map to the provided substitution. |
public List<String> getPhrases ()
Get the list of active phrases for this client.
Returns the current list of phrases. This may include both built-in and user-added phrases. Note, the capitalization may have been modified since the phrase was inserted, so please use case insensitive comparisons if parsing this, and conversions to title case or sentence case may be preferred for displaying the phrases to users.
Returns | |
---|---|
List<String> |
The complete list of phrase strings currently being recognized for this activity. |
public int getRecognizerTimeoutConfig ()
Gets the configured speech recognizer timeout value.
The speech recognizer will return to idle and listen for wake words after a configured timeout period. This allows you to query that value.
Returns | |
---|---|
int |
The timeout value in seconds. Zero indicates infinite timeout. Negative indicates an error. |
public int getRecognizerTimeoutMax ()
Gets the maximum value allowed for setRecognizerTimeoutConfig().
Returns | |
---|---|
int |
The maximum allowed timeout value in seconds. |
See also:
public boolean getSleepEnableSetting ()
Gets the system-wide "Listen while asleep" setting.
This allows speech recognition to wake the device while the screen is off when it hears the wake word: ("Hello Vuzix")
Returns | |
---|---|
boolean |
The value of the sleep enable settings as a boolean |
Throws | |
---|---|
Exception |
public VuzixSpeechClient.SpeechTolerance getSpeechTolerance ()
Gets the system-wide "Pronunciation tolerance" setting.
This value determines how correctly the user must speak each phrase.
Returns | |
---|---|
VuzixSpeechClient.SpeechTolerance |
The speech Tolerance value as a SpeechTolerance enum. |
Throws | |
---|---|
Exception |
See also:
public List<String> getStopPhrases ()
Gets all stop phrases including pre-defined and those created by calling insertStopPhrase(java.lang.String)
.
Returns | |
---|---|
List<String> |
List of phrase strings that stop previous scrolling behavior. |
See also:
public List<String> getStoredVocabularyNames ()
Lists all vocabularies previously saved by the current activity.
Vocabularies may have previously been saved by calling storeVocabulary(java.lang.String)
. This
retrieves the list of all such vocabularies. The names are valid for calls to retrieveVocabulary(java.lang.String)
and removeVocabulary(java.lang.String)
Returns | |
---|---|
List<String> |
List of names provided to storeVocabulary(java.lang.String) |
Throws | |
---|---|
RemoteException |
if the speech engine service is not running on the device. |
public String getSubstitution (String phrase)
Get the optional substitution associated with a phrase.
Any phrase added with the insertPhrase(java.lang.String, java.lang.String)
method will have an optional
substitution associated with it. This method allows retrieval of the substitution associated with
a given phrase.
Parameters | |
---|---|
phrase |
String : The phrase as passed to insertPhrase(java.lang.String, java.lang.String) . |
Returns | |
---|---|
String |
substitution as passed to insertPhrase(java.lang.String, java.lang.String) or null
if the phrase is not found. |
public List<String> getVoiceOffPhrases ()
Gets all voice-off phrases including pre-defined and those created by calling insertVoiceOffPhrase(java.lang.String)
.
Returns | |
---|---|
List<String> |
List of phrase strings that disable speech input. |
See also:
public List<String> getWakeWordPhrases ()
Gets all wake-words including pre-defined and those created by calling insertWakeWordPhrase(java.lang.String)
.
Returns | |
---|---|
List<String> |
List of phrase strings that wake the device. |
See also:
public boolean insertIntentPhrase (String phrase, String intentLabel, String params)
Insert a phrase to generate the specified intent upon the phrase being detected, with extra undocumented parameters.
Similar to insertIntentPhrase(java.lang.String, java.lang.String)
. This should only be
used when directed by Vuzix Technical Support.
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen. This should likely be a
localized string from a resource file. |
intentLabel |
String : The label matching one previously registered using defineIntent(java.lang.String, android.content.Intent) . |
params |
String : String parameters (undocumented - use only under the direction of Vuzix technical
support). |
Returns | |
---|---|
boolean |
True if the phrase is added. False otherwise. |
Throws | |
---|---|
IllegalArgumentException |
if the phrase, intentLabel, or params are not valid. |
RemoteException |
if the speech engine service is not running on the device. |
See also:
public boolean insertIntentPhrase (String phrase, String intentLabel)
Insert a phrase to generate the specified intent upon the phrase being detected.
If the preformed intent is not sufficient for the app use case, an arbitrarily defined intent may be used. In this case, the intent must be defined for the vocabulary as well as be registered in the app's intent filter and parsed in the app's intent receiver.
A free-form intent may have an arbitrarily specified Action, Data, Type, and Component, and may contain extras. The extras are limited to Boolean, Integer, and String types. Probably the most useful free-form intent case is use of a custom Action; this will target the broadcast intent from the recognizer to this application.
The Intent to be broadcast must be specified to the vocabulary using defineIntent(java.lang.String, android.content.Intent)
before the associated intentLabel can be used here.
Note: Intents are sent with sendBroadcastAsUser() from the service. They will not start new activities as would happen from startActivityForResult().
Note that the same intent (as identified by this label) may be associated with many phrases:
sc.insertIntentPhrase("focus image", “cam_focus”);sc.insertIntentPhrase("do focus", “cam_focus”); sc.insertIntentPhrase("sharpen image", “cam_focus”);
(While these examples use fixed strings for the sake of clarity, the use of string resources to facilitate localization is highly recommended.)
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen. This should likely be a
localized string from a resource file. |
intentLabel |
String : The label matching one previously registered using defineIntent(java.lang.String, android.content.Intent) . |
Returns | |
---|---|
boolean |
True if the phrase is added. False otherwise. |
Throws | |
---|---|
RemoteException |
if the speech engine service is not running on the device. |
See also:
public boolean insertKeycodePhrase (String phrase, int keycode, int repeatIntervalMs, String params)
Inserts a phrase to generate a keycode that will be sent repeatedly upon detection, with extra undocumented capabilities.
Sending repeating keycodes provides the ability to make scrolling behavior.
Similar to insertKeycodePhrase(java.lang.String, int)
. This adds optional repeat
interval and optional internal speech recognizer parameters.
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen. This should likely
be a localized string from a resource file. |
keycode |
int : The key code as defined in android.view.KeyEvent (ie: KEYCODE_ENTER) |
repeatIntervalMs |
int : The interval in milliseconds at which the keycode event will be
generated. |
params |
String : Additional parameters (undocumented - use only under the direction of Vuzix
technical support). |
Returns | |
---|---|
boolean |
True if the phrase is added. False otherwise. |
Throws | |
---|---|
IllegalArgumentException |
if the phrase is not valid. |
public boolean insertKeycodePhrase (String phrase, int keycode)
Inserts a phrase to generate a keycode that will be sent upon detection.
This is the most basic way to insert a phrase that will generate a keycode.
Upon recognition of a phrase, the recognizer may be configured to generate an Android key event, just as if a key had been pressed on a physical keypad.
Example: sc.insertKeycodePhrase("zero", KeyEvent.KEYCODE_0); or better: sc.insertKeycodePhrase(mContext.getString(R.string.voice_cmd_zero), KeyEvent.KEYCODE_0);
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen. This should likely be a
localized string from a resource file. |
keycode |
int : The key code as defined in android.view.KeyEvent (ie: KEYCODE_ENTER). |
Returns | |
---|---|
boolean |
True if the phrase is added. False otherwise. |
public boolean insertKeycodePhrase (String phrase, int keycode, int repeatIntervalMs)
Inserts a phrase to generate a keycode that will be sent repeatedly upon detection.
Similar to insertKeycodePhrase(java.lang.String, int)
This repeats the key at the specified interval until a new phrase (e.g. "stop") is recognized
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen. This should likely be a
localized string from a resource file. |
keycode |
int : The key code as defined in android.view.KeyEvent (ie: KEYCODE_ENTER) |
repeatIntervalMs |
int : The interval in milliseconds at which the keycode event will be
generated. |
Returns | |
---|---|
boolean |
True if the phrase is added. False otherwise. |
See also:
public boolean insertKeycodePhrase (String phrase, int keycode, String params)
Inserts a phrase to generate keycodes upon detection, with extra undocumented capabilities.
Similar to insertKeycodePhrase(java.lang.String, int)
. This adds optional internal speech
recognizer parameters to be used at the direction of Vuzix technical support.
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen. This should likely be a
localized string from a resource file. |
keycode |
int : The key code as defined in android.view.KeyEvent (ie: KEYCODE_ENTER). |
params |
String : Additional parameters (undocumented - use only under direction of Vuzix technical
support). |
Returns | |
---|---|
boolean |
True if the phrase is added. False otherwise. |
See also:
public boolean insertPhrase (String phrase)
This is the most basic way to insert a phrase into the recognizer.
For Example: sc.insertPhrase("take photo"));
The phrase will be provided unchanged (note: spaces are replaced by underscores) in a "phrase" string extra in the intent as demonstrated below:
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(VuzixSpeechClient.ACTION_VOICE_COMMAND)) { String phrase = intent.getStringExtra("phrase"); if (phrase != null && phrase.equals("take_photo")) { // Do something } } }
This method is useful fur developers learning to use the Speech Client. For commercialized
apps, it is recommended that the optional substitution is provided using the method
insertPhrase(java.lang.String, java.lang.String)
instead of this method
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen. This should likely be a
localized string from a resource file. |
Returns | |
---|---|
boolean |
True if the phrase is added. False otherwise. |
Throws | |
---|---|
IllegalArgumentException |
if the phrase is not valid. |
See also:
public boolean insertPhrase (String phrase, String substitution)
Inserts a phrase and provides a substitution to make processing easier for the client.
Similar to insertPhrase(java.lang.String)
This inserts a phrase to recognize and defines a substitution. The substitution will be returned when the phrase is recognized. This is useful when dealing with localize recognition phrases. Regardless of the active language, the substitution string will always be identified to your code.
For Example, instead of: sc.insertPhrase("take photo")); use: sc.insertPhrase(mContext.getString(R.string.voice_cmd_take_photo), "take_photo");
Regardless of the active language, your code will always receive "take_photo". Your source code then does not need to be modified for localization. The strings.xml resource will take care of this. For example it might have:
English: <string name="voice_cmd_take_photo">take photo</string> French: <string name="voice_cmd_take_photo">prendre une photo</string> German: <string name="voice_cmd_take_photo">machen Sie ein Foto</string> Spanish: <string name="voice_cmd_take_photo">toma una foto</string> Chinese: <string name="voice_cmd_take_photo">拍照</string> etc.
The recognized phrase will be correctly selected based on localization (note that the recognizer itself must have the correct language recognition files loaded.)
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen. This should likely be a
localized string from a resource file. |
substitution |
String : The substitution that will be returned upon detecting the phrase. This should
likely be a constant value not a localized resource. |
Returns | |
---|---|
boolean |
True if the phrase is added. False otherwise. |
Throws | |
---|---|
IllegalArgumentException |
if the arguments are not valid. |
See also:
public boolean insertStopPhrase (String phrase)
Insert a phrase to stop any repeating character that may be active.
The engine always stops repeating characters upon recognizing any other phrase. The stop phrase allows us to recognize a valid phrase that has no other action.
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen. This should likely be a
localized string from a resource file. |
Returns | |
---|---|
boolean |
True if the phrase is added. False otherwise. |
Throws | |
---|---|
IllegalArgumentException |
public boolean insertVoiceOffPhrase (String phrase)
Insert a phrase to deactivate the recognizer, as done by "voice off" in the base vocabulary.
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen. This should likely be a
localized string from a resource file. |
Returns | |
---|---|
boolean |
True if the phrase is added. False otherwise. |
Throws | |
---|---|
IllegalArgumentException |
public boolean insertWakeWordPhrase (String phrase)
Insert a phrase to wake the recognizer, as done by "Hello, Vuzix" in the base vocabulary.
This function allows for developers to use custom wake phrase, such as "welcome to my app". The default wake phrases may be deleted if desired so that only the custom wake phrase is present.
Parameters | |
---|---|
phrase |
String : The phrase for which the Speech recognizer will listen. This should likely be a
localized string from a resource file. |
Returns | |
---|---|
boolean |
True if the phrase is added. False otherwise. |
Throws | |
---|---|
IllegalArgumentException |
public static boolean isRecognizerEnabled (Context context)
Determines if the speech recognizer is currently enabled in Settings.
Parameters | |
---|---|
context |
Context : The context from which the query is being invoked. |
Returns | |
---|---|
boolean |
True if the engine is enabled. |
public static boolean isRecognizerInitialized (Context context)
Determines if the speech recognizer has been initialized.
Note: the speech engine is initialized immediately after the system starts. Normal applications need not check this condition. But certain auto-start applications may be initialized before the speech engine. They must check this before interacting with the speech engine.
Parameters | |
---|---|
context |
Context : The context from which the query is being invoked. |
Returns | |
---|---|
boolean |
True if the engine is initialized and speech commands are possible. False if the engine is not yet initialized. |
public static boolean isRecognizerTriggered (Context context)
Determines if the speech recognizer is currently triggered and listening for the full vocabulary.
Note: this is intended to be used for an initial query of the state, and not to be continually re-queried. If you need to display an indication to the user whether the recognizer is triggered or idle, register a broadcast receiver for the intent VuzixSpeechClient.ACTION_VOICE_COMMAND
Parameters | |
---|---|
context |
Context : The context from which the query is being invoked |
Returns | |
---|---|
boolean |
True if the engine is actively listening for the full vocabulary. False if the engine is disabled entirely, or idle listening for the trigger phrase. |
public boolean removeVocabulary (String name)
Remove and delete the recognizer vocabulary in the vocabulary store represented by "name".
Parameters | |
---|---|
name |
String : The arbitrary name previously passed to storeVocabulary(java.lang.String) |
Returns | |
---|---|
boolean |
True if the vocabulary is deleted. False otherwise. |
public boolean retrieveVocabulary (String name)
Replace the current activity vocabulary with the vocabulary from the vocabulary store represented by "name".
This method replaces the current vocabulary for an activity with the saved snapshot of the activity's vocabulary in the vocabulary store represented by "name". The restored vocabulary includes phrases, substitutions, and defined intents.
Parameters | |
---|---|
name |
String : The arbitrary name previously passed to storeVocabulary(java.lang.String) |
Returns | |
---|---|
boolean |
True if the vocabulary replacement is successful. False otherwise. |
public void setBluetoothSetting (boolean value)
Sets the system-wide "Bluetooth input" setting.
This allows the system to listen to Bluetooth headset audio for speech commands whenever one is connected.
Parameters | |
---|---|
value |
boolean : boolean value to set. |
Throws | |
---|---|
Exception |
public boolean setRecognizerTimeoutConfig (int timeoutSecs)
Sets the configured speech recognizer timeout value.
The speech recognizer will return to idle and listen for wake words after a configured timeout period. This allows you to configure that value.
NOTE: This configuration is global to the system and shared by all applications.
Parameters | |
---|---|
timeoutSecs |
int : int value in seconds. Zero for infinite timeout. Range zero to
getRecognizerTimeoutMax() |
Returns | |
---|---|
boolean |
True if the recognizer configuration is updated. False otherwise. |
See also:
public void setSleepEnableSetting (boolean value)
Sets the system-wide "Listen while asleep" setting. This allows speech recognition to wake the device while the screen is off when it hears the wake word: ("Hello Vuzix")
Parameters | |
---|---|
value |
boolean : booleanm value to set. |
Throws | |
---|---|
Exception |
public void setSpeechTolerance (VuzixSpeechClient.SpeechTolerance value)
Sets the system-wide "Pronunciation tolerance" setting.
This value determines how correctly the user must speak each phrase. This method should only be used if it is exposed so each wearer can adjust the value to meet their needs.
Parameters | |
---|---|
value |
VuzixSpeechClient.SpeechTolerance : SpeechTolerance enum value to set. |
Throws | |
---|---|
Exception |
See also:
public static void startGlobalSpeechSettingsActivity (Context context)
Open the global system-wide settings screen for the speech commands. This is the same as if the user had opened Settings and navigated to the speech commands page.
Parameters | |
---|---|
context |
Context : The context from which the activity is to be started |
public boolean storeVocabulary (String name)
Save a recognizer vocabulary in the vocabulary store for later use.
At launch, an application inherits the base speech recognition vocabulary. It will typically modify this vocabulary, adding and deleting phrases to create a vocabulary suited to its use. For a static activity, this is all that is needed, but some activities may dynamically modify the content affected by speech commands, and hence need to modify the vocabulary.
The {store, retrieve, remove} mechanism allows vocabulary "snapshots" to be saved and later retrieved. The snapshot includes phrases, substitutions, and defined intents.
For example, the base vocabulary may be replaced with a vocabulary which supports basic navigation, selection, and processing. This "activity base" vocabulary is then saved, and to it is added the names of several icons being displayed. On "next page", this set of icons is replaced by a new set of icons. The activity retrieves the saved "activity base" vocabulary (which will not contain the names of the previous set of icons) and adds the names of the new set of icons being displayed.
Example: sc.storeVocabulary("SortActivityBase");
Parameters | |
---|---|
name |
String : The arbitrary name representing an activity-unique label for this vocabulary
snapshot. This label need not be localized. |
Returns | |
---|---|
boolean |
True if the vocabulary is stored. False otherwise. |