Tutorial

This tutorial explains how to use the ALSpeechRecognition module (ASR).

Note:

This tutorial is made in Python.

Creating a proxy on the module

Before calling the ASR commands, you need to create a proxy on the ASR module:

#Creates a proxy on the ALSpeechRecognition module from naoqi import ALProxy asr = ALProxy("ALSpeechRecognition",IP,9559) #IP = address of your robot

Setting the language of the ASR module

Before starting the ASR engine, you must set the language of the speech recognition system. The list of the installed languages can be obtained through the getAvailableLanguages method.

The following piece of code sets the language of the speech recognition engine to English:

#sets the language of the speech recognition to english asr.setLanguage("English")

Setting the list of words or phrases to be recognized

To set the words that should be recognized, use the setWordListAsVocabulary method.

#Example: Sets the words that need to be recognized wordList=["yes","no","hello NAO","goodbye NAO"] asr.setWordListAsVocabulary(wordList)

Note:

The following feature (the usage of the "loadVocabulary()" function) is not available for Chinese and Japanese.

If you prefer not to use the setWordListAsVocabulary function, you can directly defined a vocabulary in a .lxd file and load it with the loadVocabulary method as described below:

# Example: load the vocabulary defined in the file /home/nao/MyVocabulary.lxd asr.loadVocabulary(/home/nao/MyVocabulary.lxd)

Defining your vocabulary in a .lxd file and load it with the loadVocabulary function allows you to add alternative phonetic transcriptions that refine the automatic transcriptions of the ASR, and can improve performances. For example, if you want the speech recognition to be robust to the different pronunciations of the word "hello", you can define your vocabulary file as follows:

#!Language=English #!FSG <words>=alt("yes" "no" "hello" "goodbye" )alt; <start>=alt(<words>)alt; #!Transcriptions hello h@l@U hello h@ll@U

The phonetic alphabet used to write these phonetizations is described here: http://www.phon.ucl.ac.uk/home/sampa/.

Starting the detection

When the language and the vocabulary have been set, the recognition process can be launched by calling the "subscribe" method of the ALSpeechRecognition module. Note that subscribing to a NAOqi extractor requires that an "identification name" is also provided. This name is arbitrary but must be identical to the one used when unsubscribing.

# Example: run the speech recognition engine asr.subscribe("MyModule")

Stopping the detection

The speech recognition process is stopped by calling the "unsubscribe" method of the ALSpeechRecognition module. Note that the "identification name" that you pass to this function must be identical to the name which has been passed to the "subscribe" function.

# Example: stop the speech recognition engine which has been started above asr.unsubscribe("MyModule")

Collecting the recognized word in the memory

If a word has been recognized, the result is placed in the "WordRecognized" key of ALMemory.

As a result, you can read it by accessing this key in the ALMemory module.





Copyright © 2010 Aldebaran-Robotics - All rights reserved