我正在使用 Windows-XP 机器和 Python 2.7 上的 NAO 机器人。
我想检测语音中的标记。整个事情都奏效了,但不幸的是,我现在不得不面对 10 秒的延迟,并且没有检测到我的事件(未调用回调函数)。
首先,我的主要功能:
from naoqi import ALProxy, ALBroker
from speechEventModule import SpeechEventModule
myString = "Put that \\mrk=1\\ there."
NAO_IP = "192.168.0.105"
NAO_PORT = 9559
memory = ALProxy("ALMemory", NAO_IP, NAO_PORT)
tts = ALProxy("ALTextToSpeech", NAO_IP, NAO_PORT)
tts.enableNotifications()
myBroker = ALBroker("myBroker",
"0.0.0.0", # listen to anyone
0, # find a free port and use it
NAO_IP, # parent broker IP
NAO_PORT) # parent broker port
global SpeechEventListener
SpeechEventListener = SpeechEventModule("SpeechEventListener", memory)
memory.subscribeToEvent("ALTextToSpeech/CurrentBookMark", "SpeechEventListener", "onBookmarkDetected")
tts.say(initialString)
这里是我的演讲事件模块:
from naoqi import ALModule
from naoqi import ALProxy
NAO_IP = "192.168.0.105"
NAO_PORT = 9559
SpeechEventListener = None
leds = None
memory = None
class SpeechEventModule(ALModule):
def __init__(self, name, ext_memory):
ALModule.__init__(self, name)
global memory
memory = ext_memory
global leds
leds = ALProxy("ALLeds",NAO_IP, NAO_PORT)
def onBookmarkDetected(self, key, value, message):
print "Event detected!"
print "Key: ", key
print "Value: " , value
print "Message: " , message
if(value == 1):
global leds
leds.fadeRGB("FaceLeds", 0x00FF0000, 0.2)
if(value == 2):
global leds
leds.fadeRGB("FaceLeds", 0x000000FF, 0.2)
请问有人有同样的问题吗?有人可以给我一个建议吗?
提前致谢!