程序说明书索引 >> 红色说明书索引

>音频系统

引言

ALAudio Player (音频播放器)

ALTextToSpeech (声音合成)

ALSpeechRecognition (语音识别)

ALAudioDevice (音频器件)

ALSoundDetection(声音识别)

ALAudioSourceLocalization(音频源定位)

使用指导

本指导介绍如何在一个程序中使用ALSpeechRecognition模块(ASR)。

注释:

本指导使用Python语言编写。

在模块上创建一个代理

使用ASR命令前,您必须先在ASR模块上创建一个代理:

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

设定ASR模块的语言

在启动ASR引擎之前,您必须设定语音识别系统的语言。安装的语言表可以通过"getAvailableLanguages"方法获得。

以下范例将语音识别系统的语言设定为英语:

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

设定要识别的单词或短语表

使用“setWordListAsVocabulary”函数,设定要识别的词:

#Sets the words to recognize wordList=["yes","no","hello NAO","goodbye NAO"] asr.setWordListAsVocabulary(wordList)

注释:

当ASR引擎设定在“Chinese”(中文)上时,无法使用以下特性(使用函数"loadVocabulary()")。

如果您不想使用函数setWordListAsVocabulary,您可以直接在一个“.lxd”文件里定义一个词汇表,并如下所示,使用方法loadVocabulary来加载:

如果不使用setWordListAsVocabulary函数,您还可以直接在一个.lxd文件里定义词汇,然后使用loadVocabulary方法加载,如下所示:

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

使用.lxd文件定义词汇、然后通过loadVocabulary方法加载,这样,除可自动转录ASR外,还可以选择发音转录,以获得更好的效果。 例如,如果希望语音识别能够分辨出Hello一词的不同发音,可以如下所示定义词汇:

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

在以下网址可以查看用来书写这些按发音拼字的音标字母的说明:http://www.phon.ucl.ac.uk/home/sampa/

开始检测

当语言和词汇表都设定完成后,就可以通过调用ALSpeechRecognition模块的"subscribe"方法来运行识别进程。 请注意,订阅至一个NAOqi析取器需要提供一个"identification name"(识别名)。该名称是任意的,但在取消订阅时,必须使用同一个名称。

# runs the speech recognition engine asr.startDetection()

停止检测

要停止语音识别进程时,请调用ALSpeechRecognition模块的"unsubscribe"方法。 请注意,在该函数中使用的"identification name"(识别名)必须与在"subscribe"函数中使用的名称相同。

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

在内存中选取识别出的单词

如果机器人识别出一个单词,识别的结果就保存在ALMemory的"WordRecognized"关键码里。

这样,您就可以通过ALMemory模块里的这一关键码来读取该单词。





Copyright © 2010 Aldebaran-Robotics - 版权所有