ALSpeechRecognition gives access to the embedded voice recognition system. It can be dynamically modified. This class allows user to load the current words list that should be recognized. The result of the recognition engine is located in the ALMemory's key: "WordRecognized" The structure of the result is an array : [ (string) word , (float) confidence ]
void setVisualExpression (const bool& setOrNot)
Enables or disables the leds animations showing the state of the recognition engine during the recognition process.
Enable (true) or disable it (false).
void setAudioExpression (const bool& setOrNot)
Enables or disables the playing of sounds indicating the state of the recognition engine.
If this option is enabled, a sound is played at the beginning of the recognition process (after a call to the subscribe method), and a sound is played when the user call the unsubscribe method
Enable (true) or disable it (false).
void setLanguage (const string& languageName)
Sets the language used by the speech recognition engine. The list of the available languages can be collected through the getAvailableLanguages method. If you want to set a language as the default language (loading automatically at module launch), please refer to the web page of the robot.
Name of the language in English.
string getLanguage ()
Returns the current language used by the speech recognition system.
Current language used by the speech recognition engine.
Example in python :
#gets the current language of the speech recognition system and displays it currentLanguage=asr.getLanguage() print currentLanguage
vector<string> getAvailableLanguages ()
Returns the list of the languages installed on the system.
Array of strings that contains the list of the installed languages.
Example in python :
#gets the list of the available languages and displays it availableLanguages=asr.getAvailableLanguages() print availableLanguages
void setWordListAsVocabulary (const vector<string>& vocabulary)
Sets the list of words (vocabulary) that should be recognized by the speech recognition engine.
List of words that should be recognized
Example in python :
#Sets the words to recognize wordList=["yes","no","hello Nao","goodbye Nao"] asr.setWordListAsVocabulary(wordList)
void loadVocabulary (const string& vocabularyFile)
Loads the vocabulary to recognized contained in a .lxd file. This method is not available with the ASR engine language set to Chinese. For more informations see the red documentation
Name of the lxd file containing the vocabulary
void setParameter (const string& paramName, const float& paramValue)
Sets a parameter of the speech recognition engine. Note that when the ASR engine language is set to Chinese, no parameter can be set. The parameters that can be set and the corresponding values are: "EarUseSpeechDetector" - Values : 0 (No), 1 (Regular), or 2 (Cepstral) : type of speech detector used by the ASR engine - default value is 2. "EarSpeed" - Values : 0 to 3 - 0 is slowest and most accurate. 3 is the fastest but may add some recognition errors, especially if you talk fast because some parts of the audio data is not processed. - default value is 2. "EarUseFilter" : Values : 0 (no) or 1 (yes) - Applies a High-Pass filter on the input signal - default value is 0.
Name of the parameter.
Value of the parameter.
Example in python :
#Sets the EarSpeed parameter to 3 asr.setParameter("EarSpeed", 3.0)
float getParameter (const string& paramName)
Gets a parameter of the speech recognition engine. Note that when the ASR engine language is set to Chinese, no parameter can be retrieved
Name of the parameter.
Value of the parameter.
vector<string> getPhoneticTranscription (const string& word)
This function allows you to get the phonetic transcription(s) used by the speech recognition engine when it is asked to recognize a word. Note that when the ASR engine language is set to Chinese, no phonetic transcription can be retrieved.
Word to phoneticize.
Phonetic transcription(s) of the word
string version ()
Returns the version of the module.
A string containing the version of the module.
AL::ALValue getMethodHelp (const string& methodName)
Retrieves a method's description.
The name of the method.
A structure containing the method's description.
AL::ALValue getModuleHelp ()
Retrieves the module's description.
A structure describing the module.
string getUsage (const string& name)
Gets the method usage string. This summarise how to use the method.
The name of the method.
A string that summarises the usage of the method.
void subscribe (const string& name, const int& period, const float& precision)
Subscribes to the extractor. This causes the extractor to start writing information to memory using the keys described by getOutputNames(). These can be accessed in memory using ALMemory.getData("keyName"). In many cases you can avoid calling subscribe on the extractor by just calling ALMemory.subscribeToEvent() supplying a callback method. This will automatically subscribe to the extractor for you.
Name of the module which subscribes.
Refresh period (in milliseconds) if relevant.
Precision of the extractor if relevant.
void subscribe (const string& name)
Subscribes to the extractor. This causes the extractor to start writing information to memory using the keys described by getOutputNames(). These can be accessed in memory using ALMemory.getData("keyName"). In many cases you can avoid calling subscribe on the extractor by just calling ALMemory.subscribeToEvent() supplying a callback method. This will automatically subscribe to the extractor for you.
Name of the module which subscribes.
void unsubscribe (const string& name)
Unsubscribes from the extractor.
Name of the module which had subscribed.
void updatePeriod (const string& name, const int& period)
Updates the period if relevant.
Name of the module which has subscribed.
Refresh period (in milliseconds).
void updatePrecision (const string& name, const float& precision)
Updates the precision if relevant.
Name of the module which has subscribed.
Precision of the extractor.
int getMyPeriod (const string& name)
Gets the period for a specific subscription.
Name of the module which has subscribed.
Refresh period (in milliseconds).
float getMyPrecision (const string& name)
Gets the precision for a specific subscription.
name of the module which has subscribed
precision of the extractor
AL::ALValue getSubscribersInfo ()
Gets the parameters given by the module.
Array of names and parameters of all subscribers.
vector<string> getOutputNames ()
Get the list of values updated in ALMemory.
Array of values updated by this extractor in ALMemory
void setDebugMode (const bool& bSetOrUnset)
enable/disable the printing of some debug information
enable the functionnality when true.