Class VuzixSpeechClient

java.lang.Object
com.vuzix.sdk.speechrecognitionservice.VuzixSpeechClient

public class VuzixSpeechClient extends Object
Vuzix Speech Recognition Client SDK

Introduction

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.

Custom Vocabulary Architecture

The Vuzix Speech Recognizer is notified of context switches in Android when each activity's onResume() is called. In response, the recognizer checks for a custom vocabulary associated with the resumed activity. If found, the recognizer switches to this vocabulary. Any activity without a custom vocabulary will instead use the base vocabulary.

Custom Vocabulary Usage

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.

Getting Started

New users should start with the simplest command: insertPhrase(String phrase)
Since:
SDK version 1.2
See Also:
  • Field Details

    • ACTION_VOICE_COMMAND

      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));
       
      Since:
      SDK version 1.2
      See Also:
    • BUILT_IN_ACTION_ASSISTANT

      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.
      See Also:
    • BUILT_IN_ACTION_ASSIST_ALEXA

      public static final int BUILT_IN_ACTION_ASSIST_ALEXA
      Parameter for getBuiltInActionPhrases(int) to request phrases associated with launching the Alexa application.
      See Also:
    • BUILT_IN_ACTION_ASSIST_GOOGLE

      public static final int BUILT_IN_ACTION_ASSIST_GOOGLE
      Parameter for getBuiltInActionPhrases(int) to request phrases associated with launching the Google Assistant application.
      See Also:
    • BUILT_IN_ACTION_CLEAR_NOTIFICATIONS

      public static final int BUILT_IN_ACTION_CLEAR_NOTIFICATIONS
      Parameter for getBuiltInActionPhrases(int) to request phrases associated with clearing all Android notifications.
      See Also:
    • BUILT_IN_ACTION_COMMAND_LIST

      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.
      See Also:
    • BUILT_IN_ACTION_FLASHLIGHT_OFF

      public static final int BUILT_IN_ACTION_FLASHLIGHT_OFF
      Parameter for getBuiltInActionPhrases(int) to request phrases associated with turning off the flashlight.
      See Also:
    • BUILT_IN_ACTION_FLASHLIGHT_ON

      public static final int BUILT_IN_ACTION_FLASHLIGHT_ON
      Parameter for getBuiltInActionPhrases(int) to request phrases associated with turning on the flashlight.
      See Also:
    • BUILT_IN_ACTION_SLEEP

      public static final int BUILT_IN_ACTION_SLEEP
      Parameter for getBuiltInActionPhrases(int) to request phrases associated with causing the system to go to sleep.
      See Also:
    • BUILT_IN_ACTION_SPEECH_SETTINGS

      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.
      See Also:
    • BUILT_IN_ACTION_START_RECORDING

      public static final int BUILT_IN_ACTION_START_RECORDING
      Parameter for getBuiltInActionPhrases(int) to request phrases associated with recording a video.
      See Also:
    • BUILT_IN_ACTION_TAKE_PHOTO

      public static final int BUILT_IN_ACTION_TAKE_PHOTO
      Parameter for getBuiltInActionPhrases(int) to request phrases associated with taking a photograph.
      See Also:
    • BUILT_IN_ACTION_VIEW_NOTIFICATIONS

      public static final int BUILT_IN_ACTION_VIEW_NOTIFICATIONS
      Parameter for getBuiltInActionPhrases(int) to request phrases associated with viewing the system Android notifications.
      See Also:
    • EXTRA_PAUSE_ACCESSIBILITY

      public static final String EXTRA_PAUSE_ACCESSIBILITY
      String extra sent only to AccessibilityService to request pause/resume
      Since:
      SDK version 1.94
      See Also:
    • EXTRA_VOCAB_KB_PHRASES

      public static final String EXTRA_VOCAB_KB_PHRASES
      String extra used only by InputMethodService to provide a phrase.
      Since:
      SDK version 1.8
      See Also:
    • EXTRA_VOCAB_KB_SUBSTITUTION

      public static final String EXTRA_VOCAB_KB_SUBSTITUTION
      String extra used only by InputMethodService to provide a substitution.
      Since:
      SDK version 1.8
      See Also:
    • EXTRA_VOCAB_RELOAD_REQUIRED

      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.
      Since:
      SDK version 1.96
      See Also:
    • KEY_FREQ_REPEATING

      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)
      See Also:
    • KEY_FREQ_SINGLE_OR_REPEAT

      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)
      See Also:
    • KEY_FREQ_SINGLE_PRESS

      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)
      See Also:
    • PHRASE_STRING_EXTRA

      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.

      Since:
      SDK version 1.2
      See Also:
    • RECOGNIZER_ACTIVE_BOOL_EXTRA

      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

      Since:
      SDK version 1.4
      See Also:
  • Constructor Details

    • VuzixSpeechClient

      public VuzixSpeechClient(android.app.Activity activity) throws android.os.RemoteException
      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 - The Activity in which this custom vocabulary will operate.
      Throws:
      android.os.RemoteException - if the Vuzix speech engine is not running on this device.
      Since:
      SDK version 1.2
    • VuzixSpeechClient

      @Deprecated public VuzixSpeechClient(android.app.Fragment fragment) throws IllegalArgumentException, android.os.RemoteException
      Deprecated.
      This is only supported by M300. Newer products do not support this. 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 - The Fragment in which this custom vocabulary will operate.
      Throws:
      android.os.RemoteException - if the Vuzix speech engine service is not running on this device.
      IllegalArgumentException - if the device does not support this interface.
      Since:
      SDK version 1.2
    • VuzixSpeechClient

      public VuzixSpeechClient(android.inputmethodservice.InputMethodService service) throws android.os.RemoteException
      Constructs a speech SDK client for an InputMethodService. Using this will install the custom vocabulary for your InputMethodService.
      Parameters:
      service - The InputMethodService in which this custom vocabulary will operate.
      Throws:
      android.os.RemoteException - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.8
    • VuzixSpeechClient

      public VuzixSpeechClient(android.accessibilityservice.AccessibilityService service) throws android.os.RemoteException
      Constructs a speech SDK client for an AccessibilityService Using this will install the custom vocabulary for your AccessibilityService.
      Parameters:
      service - The AccessibilityService in which this custom vocabulary will operate.
      Throws:
      android.os.RemoteException - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.92
  • Method Details

    • dump

      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:
      A single String with a phrase pair per row, separated by carriage returns.
      Since:
      SDK version 1.2
      See Also:
    • getPhrases

      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:
      The complete list of phrase strings currently being recognized for this activity.
      Since:
      SDK version 1.6
    • getBuiltInActionPhrases

      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.

      Parameters:
      builtInAction - - May be one of:
      Returns:
      List of phrase strings that match the specified built-in action.
      Since:
      SDK version 1.8
    • getPhrases

      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 - 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 of phrase strings that map to the provided substitution.
      Since:
      SDK version 1.8
    • insertPhrase

      public boolean insertPhrase(String phrase) throws IllegalArgumentException
      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 - The phrase for which the Speech recognizer will listen. This should likely be a localized string from a resource file.
      Returns:
      True if the phrase is added. False otherwise.
      Throws:
      IllegalArgumentException - if the phrase is not valid.
      Since:
      SDK version 1.2
      See Also:
    • insertPhrase

      public boolean insertPhrase(String phrase, String substitution) throws IllegalArgumentException
      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 - The phrase for which the Speech recognizer will listen. This should likely be a localized string from a resource file.
      substitution - The substitution that will be returned upon detecting the phrase. This should likely be a constant value not a localized resource.
      Returns:
      True if the phrase is added. False otherwise.
      Throws:
      IllegalArgumentException - if the arguments are not valid.
      Since:
      SDK version 1.2
      See Also:
    • getSubstitution

      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 - The phrase as passed to insertPhrase(java.lang.String,java.lang.String).
      Returns:
      substitution as passed to insertPhrase(java.lang.String,java.lang.String) or null if the phrase is not found.
      Since:
      SDK version 1.9
    • insertKeycodePhrase

      public boolean insertKeycodePhrase(String phrase, int keycode, int repeatIntervalMs, String params) throws IllegalArgumentException
      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 - The phrase for which the Speech recognizer will listen. This should likely be a localized string from a resource file.
      keycode - The key code as defined in android.view.KeyEvent (ie: KEYCODE_ENTER)
      repeatIntervalMs - The interval in milliseconds at which the keycode event will be generated.
      params - Additional parameters (undocumented - use only under the direction of Vuzix technical support).
      Returns:
      True if the phrase is added. False otherwise.
      Throws:
      IllegalArgumentException - if the phrase is not valid.
      Since:
      SDK version 1.2
      See Also:
    • insertKeycodePhrase

      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 - The phrase for which the Speech recognizer will listen. This should likely be a localized string from a resource file.
      keycode - The key code as defined in android.view.KeyEvent (ie: KEYCODE_ENTER).
      params - Additional parameters (undocumented - use only under direction of Vuzix technical support).
      Returns:
      True if the phrase is added. False otherwise.
      Since:
      SDK version 1.2
      See Also:
    • insertKeycodePhrase

      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 keycode)

      This repeats the key at the specified interval until a new phrase (e.g. "stop") is recognized

      Parameters:
      phrase - The phrase for which the Speech recognizer will listen. This should likely be a localized string from a resource file.
      keycode - The key code as defined in android.view.KeyEvent (ie: KEYCODE_ENTER)
      repeatIntervalMs - The interval in milliseconds at which the keycode event will be generated.
      Returns:
      True if the phrase is added. False otherwise.
      Since:
      SDK version 1.2
      See Also:
    • insertKeycodePhrase

      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 - The phrase for which the Speech recognizer will listen. This should likely be a localized string from a resource file.
      keycode - The key code as defined in android.view.KeyEvent (ie: KEYCODE_ENTER).
      Returns:
      True if the phrase is added. False otherwise.
      Since:
      SDK version 1.2
    • getKeycodePhrases

      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 - The key code as defined in android.view.KeyEvent (ie: KEYCODE_ENTER)
      keyFrequency - May be one of
      Returns:
      List of phrase strings matching the criteria.
      Since:
      SDK version 1.8
    • getMappedKeycodes

      public List<Integer> getMappedKeycodes(int keyFrequency)
      Get all keycodes that have an associated phrase in the vocabulary.
      Parameters:
      keyFrequency - May be one of
      Returns:
      List of key code values (as defined in android.view.KeyEvent) with which there is currently a speech phrase associated.
      Since:
      SDK version 1.8
    • convertPhraseToReplyFormat

      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 - The phrase for which the Speech recognizer will listen
      Returns:
      String modified to match what is returned by the speech engine
      Since:
      SDK version 1.93
    • insertIntentPhrase

      public boolean insertIntentPhrase(String phrase, String intentLabel, String params) throws IllegalArgumentException, android.os.RemoteException
      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 - The phrase for which the Speech recognizer will listen. This should likely be a localized string from a resource file.
      intentLabel - The label matching one previously registered using defineIntent(java.lang.String,android.content.Intent).
      params - String parameters (undocumented - use only under the direction of Vuzix technical support).
      Returns:
      True if the phrase is added. False otherwise.
      Throws:
      IllegalArgumentException - if the phrase, intentLabel, or params are not valid.
      android.os.RemoteException - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.2
      See Also:
    • insertIntentPhrase

      public boolean insertIntentPhrase(String phrase, String intentLabel) throws android.os.RemoteException
      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 - The phrase for which the Speech recognizer will listen. This should likely be a localized string from a resource file.
      intentLabel - The label matching one previously registered using defineIntent(java.lang.String,android.content.Intent).
      Returns:
      True if the phrase is added. False otherwise.
      Throws:
      android.os.RemoteException - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.2
      See Also:
    • getIntentPhrases

      public List<String> getIntentPhrases(String intentLabel)
      Gets the phrases associated with a specific intent label.
      Parameters:
      intentLabel - The label matching one previously registered using defineIntent(java.lang.String,android.content.Intent).
      Returns:
      List of phrase strings matching the criteria.
      Since:
      SDK version 1.8
    • insertWakeWordPhrase

      public boolean insertWakeWordPhrase(String phrase) throws IllegalArgumentException
      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 - The phrase for which the Speech recognizer will listen. This should likely be a localized string from a resource file.
      Returns:
      True if the phrase is added. False otherwise.
      Throws:
      IllegalArgumentException
      Since:
      SDK version 1.5
    • getWakeWordPhrases

      public List<String> getWakeWordPhrases()
      Gets all wake-words including pre-defined and those created by calling insertWakeWordPhrase(java.lang.String).
      Returns:
      List of phrase strings that wake the device.
      Since:
      SDK version 1.8
      See Also:
    • insertStopPhrase

      public boolean insertStopPhrase(String phrase) throws IllegalArgumentException
      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 - The phrase for which the Speech recognizer will listen. This should likely be a localized string from a resource file.
      Returns:
      True if the phrase is added. False otherwise.
      Throws:
      IllegalArgumentException
      Since:
      SDK version 1.8
    • getStopPhrases

      public List<String> getStopPhrases()
      Gets all stop phrases including pre-defined and those created by calling insertStopPhrase(java.lang.String).
      Returns:
      List of phrase strings that stop previous scrolling behavior.
      Since:
      SDK version 1.8
      See Also:
    • insertVoiceOffPhrase

      public boolean insertVoiceOffPhrase(String phrase) throws IllegalArgumentException
      Insert a phrase to deactivate the recognizer, as done by "voice off" in the base vocabulary.
      Parameters:
      phrase - The phrase for which the Speech recognizer will listen. This should likely be a localized string from a resource file.
      Returns:
      True if the phrase is added. False otherwise.
      Throws:
      IllegalArgumentException
      Since:
      SDK version 1.3
    • getVoiceOffPhrases

      public List<String> getVoiceOffPhrases()
      Gets all voice-off phrases including pre-defined and those created by calling insertVoiceOffPhrase(java.lang.String).
      Returns:
      List of phrase strings that disable speech input.
      Since:
      SDK version 1.8
      See Also:
    • deleteAllPhrasesExcept

      public boolean deleteAllPhrasesExcept(List<String> exceptions)
      Deletes all phrases except the list that you wish to keep.
      Parameters:
      exceptions - The list of phrases to keep. All other phrases will be deleted.
      Returns:
      True if all phrases other than the exception list are deleted successfully.
      Since:
      SDK version 1.8
    • deleteAllPhrases

      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:
      True if all phrases are deleted successfully.
      Since:
      SDK version 1.8
    • deletePhrase

      public boolean deletePhrase(String phrase) throws IllegalArgumentException
      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 - The phrase to be deleted from the speech recognition map.
      Returns:
      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.
      Since:
      SDK version 1.2
    • defineIntent

      public boolean defineIntent(String label, android.content.Intent intent) throws android.os.RemoteException
      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 - An arbitrary label by which this new Intent will be identified during insertIntentPhrase(java.lang.String,java.lang.String)
      intent - The Intent your Activity wishes to receive.
      Returns:
      True if the Intent can be defined. False otherwise.
      Throws:
      android.os.RemoteException - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.2
      See Also:
    • deleteIntent

      public boolean deleteIntent(String label) throws android.os.RemoteException
      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 - - the unique string label provided previously to defineIntent(java.lang.String,android.content.Intent)
      Returns:
      True if the intent is deleted. False otherwise.
      Throws:
      android.os.RemoteException - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.91
      See Also:
    • getIntentLabels

      public List<String> getIntentLabels() throws android.os.RemoteException
      Lists all available intent labels as previously defined by calls to defineIntent(java.lang.String,android.content.Intent).
      Returns:
      All labels provided to defineIntent(java.lang.String,android.content.Intent).
      Throws:
      android.os.RemoteException - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.91
      See Also:
    • storeVocabulary

      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 - The arbitrary name representing an activity-unique label for this vocabulary snapshot. This label need not be localized.
      Returns:
      True if the vocabulary is stored. False otherwise.
      Since:
      SDK version 1.4
    • removeVocabulary

      public boolean removeVocabulary(String name)
      Remove and delete the recognizer vocabulary in the vocabulary store represented by "name".
      Parameters:
      name - The arbitrary name previously passed to storeVocabulary(java.lang.String)
      Returns:
      True if the vocabulary is deleted. False otherwise.
      Since:
      SDK version 1.4
    • retrieveVocabulary

      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 - The arbitrary name previously passed to storeVocabulary(java.lang.String)
      Returns:
      True if the vocabulary replacement is successful. False otherwise.
      Since:
      SDK version 1.4
    • getStoredVocabularyNames

      public List<String> getStoredVocabularyNames() throws android.os.RemoteException
      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 of names provided to storeVocabulary(java.lang.String)
      Throws:
      android.os.RemoteException - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.91
    • control

      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 - The text type of the control. Provided by Vuzix technical support in limited applications.
      params - The text value to set to the control. Provided by Vuzix technical support in limited applications.
      Returns:
      True if the control is set. False otherwise.
      Since:
      SDK version 1.4
    • control

      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 - The text type of the control. Provided by Vuzix technical support in limited applications.
      Returns:
      True if the control is set. False otherwise.
      Since:
      SDK version 1.4
    • CancelRepeatingCharacters

      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:
      True if the no characters are now repeating. False otherwise.
      Since:
      SDK version 1.6
    • TriggerVoiceAudio

      @Deprecated public static void TriggerVoiceAudio(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.

      Parameters:
      triggered - True to trigger the recognizer. False to put it to sleep.
      Since:
      SDK version 1.4
    • TriggerVoiceAudio

      @Deprecated public static void TriggerVoiceAudio()
      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.

      Since:
      SDK version 1.3
    • TriggerVoiceAudio

      public static void TriggerVoiceAudio(android.content.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 - The context from which the trigger is being invoked
      triggered - True to trigger the recognizer. False to put it to sleep.
      Since:
      SDK version 1.4
    • TriggerVoiceAudio

      public static void TriggerVoiceAudio(android.content.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 - The context from which the trigger is being invoked
      Since:
      SDK version 1.3
      See Also:
    • EnableRecognizer

      @Deprecated public static void EnableRecognizer(boolean enabled)
      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 - True to enable the recognizer. False to disable it.
      Since:
      SDK version 1.3
      See Also:
    • EnableRecognizer

      public static void EnableRecognizer(android.content.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 - The context from which the trigger is being invoked.
      enabled - True to enable voice recognition. False to disable.
      Since:
      SDK version 1.3
    • isRecognizerEnabled

      public static boolean isRecognizerEnabled(android.content.Context context)
      Determines if the speech recognizer is currently enabled in Settings.
      Parameters:
      context - The context from which the query is being invoked.
      Returns:
      True if the engine is enabled.
      Since:
      SDK version 1.7
    • isRecognizerTriggered

      public static boolean isRecognizerTriggered(android.content.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 - The context from which the query is being invoked
      Returns:
      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.
      Since:
      SDK version 1.7
    • getRecognizerTimeoutConfig

      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:
      The timeout value in seconds. Zero indicates infinite timeout. Negative indicates an error.
      Since:
      SDK version 1.91
    • getRecognizerTimeoutMax

      public int getRecognizerTimeoutMax()
      Gets the maximum value allowed for setRecognizerTimeoutConfig().
      Returns:
      The maximum allowed timeout value in seconds.
      Since:
      SDK version 1.91
      See Also:
    • setRecognizerTimeoutConfig

      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 value in seconds. Zero for infinite timeout. Range zero to getRecognizerTimeoutMax()
      Returns:
      True if the recognizer configuration is updated. False otherwise.
      Since:
      SDK version 1.91
      See Also:
    • isRecognizerInitialized

      public static boolean isRecognizerInitialized(android.content.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 - The context from which the query is being invoked.
      Returns:
      True if the engine is initialized and speech commands are possible. False if the engine is not yet initialized.
      Since:
      SDK version 1.7
    • startGlobalSpeechSettingsActivity

      public static void startGlobalSpeechSettingsActivity(android.content.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 - The context from which the activity is to be started
      Since:
      SDK version 1.95
    • getEngineVersion

      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:
      The speech engine version number running on the current hardware.
      Since:
      SDK version 1.8
    • getSpeechTolerance

      public VuzixSpeechClient.SpeechTolerance getSpeechTolerance() throws Exception
      Gets the system-wide "Pronunciation tolerance" setting.

      This value determines how correctly the user must speak each phrase.

      Returns:
      The speech Tolerance value as a SpeechTolerance enum.
      Throws:
      Exception - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.97
      See Also:
    • setSpeechTolerance

      public void setSpeechTolerance(VuzixSpeechClient.SpeechTolerance value) throws Exception
      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 - SpeechTolerance enum value to set.
      Throws:
      Exception - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.97
      See Also:
    • getBluetoothSetting

      public boolean getBluetoothSetting() throws Exception
      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:
      The value of the headset settings as a boolean
      Throws:
      Exception - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.97
    • setBluetoothSetting

      public void setBluetoothSetting(boolean value) throws Exception
      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 value to set.
      Throws:
      Exception - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.97
    • getSleepEnableSetting

      public boolean getSleepEnableSetting() throws Exception
      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:
      The value of the sleep enable settings as a boolean
      Throws:
      Exception - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.97
    • setSleepEnableSetting

      public void setSleepEnableSetting(boolean value) throws Exception
      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 - booleanm value to set.
      Throws:
      Exception - if the Vuzix speech engine service is not running on this device.
      Since:
      SDK version 1.97