本文整理汇总了Python中naoqi.ALProxy.setVisualExpression方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.setVisualExpression方法的具体用法?Python ALProxy.setVisualExpression怎么用?Python ALProxy.setVisualExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.setVisualExpression方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NAOVoiceRec
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setVisualExpression [as 别名]
class NAOVoiceRec(ALModule):
def __init__(self, id, ip, port, wordList, callBack, wordSpotting=True, visualExpression=True, audioExpression=False):
super(NAOVoiceRec, self).__init__(id)
self.id = id
self.wordCallBack = callBack;
#create the speech recognition proxy
self.speechRec = ALProxy("ALSpeechRecognition", ip, port)
#set the language
self.speechRec.setLanguage("English")
#load the vocabulary
self.speechRec.setVocabulary(wordList, wordSpotting)
self.speechRec.subscribe(id)
# configure expressions
self.speechRec.setVisualExpression(visualExpression)
self.speechRec.setAudioExpression(audioExpression)
#get the ALMemory Proxy and subscribe to the events
self.memProx = ALProxy("ALMemory")
self.memProx.subscribeToEvent("WordRecognized", self.id, "wordRecognized")
def __del__(self):
self.speechRec.unsubscribe(self.id)
self.memProx.unsubscribeToEvent("WordRecognized", self.id)
def wordRecognized(self, event, words, id):
self.wordCallBack(words)
示例2: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setVisualExpression [as 别名]
def __init__(self, name):
ALModule.__init__(self, name)
self.tts = ALProxy("ALTextToSpeech", "138.110.234.37", 9559)
asr = ALProxy("ALSpeechRecognition", "138.110.234.37", 9559)
global memory
memory = ALProxy("ALMemory")
memory.subscribeToEvent("WordRecognized", "Test", "onWordRecognized")
asr.pause(True)
asr.setVocabulary(["cabbage", "hello", "punch"], True)
asr.setAudioExpression(True)
asr.setVisualExpression(True)
asr.pause(False)
示例3: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setVisualExpression [as 别名]
def __init__(self, name):
ALModule.__init__(self, name)
# No need for IP and port here because
# we have our Python broker connected to NAOqi broker
# Create a proxy to ALTextToSpeech for later use
self.tts = ALProxy("ALTextToSpeech")
asr = ALProxy("ALSpeechRecognition")
asr.pause(True)
asr.setVocabulary(["point"], True)
asr.setAudioExpression(True)
asr.setVisualExpression(True)
asr.pause(False)
# Subscribe to the FaceDetected event:
global memory
memory = ALProxy("ALMemory")
memory.subscribeToEvent("WordRecognized", "Test", "onWordRecognized")
示例4: ALProxy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setVisualExpression [as 别名]
import sys
import time
import random
import motion
from naoqi import ALProxy
tts = ALProxy("ALTextToSpeech","nao.local",9559)
sr = ALProxy("ALSpeechRecognition","nao.local",9559)
memProxy = ALProxy("ALMemory","nao.local",9559)
motion = ALProxy("ALMotion","nao.local",9559)
sr.setVocabulary(["oui","non","un","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","douze","quatorze","quinze","seize","dix-huit","vingt","vingt-et-un","vingt-quatre","vingt-cinq","vingt-sept","vingt-huit","trente","trente-deux","trente-cinq","trente-six","quarante","quarante-deux","quarante-cinq","quarante-huit","quarante-neuf","cinquante","cinquante-quatre","cinquante-six","soixante","soixante-trois","soixante-quatre","soixante-dix","soixante-douze","quatre-vingts","quatre-vingt-un","quatre-vingt-dix","cent"],True)
sr.setAudioExpression(True)
sr.setVisualExpression(True)
fini = False
x = "WordRecognized"
cpt = 3
def onWordRecognized(x,total):
"""Ici on regarde le mot reconnu si l'indice de fiabilité est supérieur à 0.5 """
retVal = memProxy.getData("WordRecognized")
print x, retVal[0], retVal[1]
print total
if(retVal[0] != "" and retVal[1]>0.5):
if(retVal[0] == "un" and total == 1):
return True
elif retVal[0] == "deux" and total == 2:
return True
示例5: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setVisualExpression [as 别名]
#.........这里部分代码省略.........
def headmove(self, angles,speed):
if self.headlock == True:
return
self.headlock == True
Id = self.motionProxy.post.setAngles(["HeadYaw", "HeadPitch"], angles, speed)
self.motionProxy.wait(Id, 0)
self.headlock == False
def search(self):
prevodom = self.headOdom
self.headmove([-0.8,self.headOdom[1]],0.1)
time.sleep(2)
if self.stop == False :
self.headmove([0.8, self.headOdom[1]],0.1)
time.sleep(2)
#return to original
if self.stop == False:
self.headmove(prevodom,0.1)
self.stop = False
def audio_callback(self,msg):
if self.speechini == False :
self.speechini = True
self.asr.pause(True)
self.vocabulary = ["yes", "no", "please", "hello","the","be","to","of","and","in","that","have","it","robot"]
self.asr.setVocabulary(self.vocabulary, True)
self.asr.setVisualExpression(True)
self.asr.setAudioExpression(True)
self.asr.subscribe("ASR")
self.asr.pause(False)
nodetectionCount = 0
# print msg.azimuth.data
while True:
time.sleep(0.8)
speech = self.memoryProxy.getData(self.memValue, 0)
voice = self.memoryProxy.getData('SpeechDetected', 0)
if (voice ==1 ):
if speech[1] > 0.1:
nodetectionCount =0
self.speechPub.publish(True)
return
else:
nodetectionCount +=1
if nodetectionCount >10:
self.asr.pause(True)
return
def navigate(self,x):
self.checkawake()
self.motionProxy.moveTo(x,0,0)
def rotate(self,z):
self.checkawake()
示例6: SpeechRecognitionWrapper
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setVisualExpression [as 别名]
class SpeechRecognitionWrapper(ALModule):
"""ROS wrapper for Naoqi speech recognition"""
def __init__(self, ip, port, publisher, config):
# Get a (unique) name for naoqi module which is based on the node name
# and is a valid Python identifier (will be useful later)
self.naoqi_name = Util.to_naoqi_name( rospy.get_name() )
#Start ALBroker (needed by ALModule)
self.broker = ALBroker(self.naoqi_name + "_broker",
"0.0.0.0", # listen to anyone
0, # find a free port and use it
ip, # parent broker IP
port ) # parent broker port
#Init superclass ALModule
ALModule.__init__( self, self.naoqi_name )
# Start naoqi proxies
self.memory = ALProxy("ALMemory")
self.proxy = ALProxy("ALSpeechRecognition")
#Keep publisher to send word recognized
self.pub = publisher
#Install global variables needed by Naoqi
self.install_naoqi_globals()
#Check no one else is subscribed to this event
subscribers = self.memory.getSubscribers(Constants.EVENT)
if subscribers:
rospy.logwarn("Speech recognition already in use by another node")
for module in subscribers:
self.stop(module)
# Configure this instance
self.reconfigure(config)
#And subscribe to the event raised by speech recognition
rospy.loginfo("Subscribing '{}' to NAO speech recognition".format(
self.naoqi_name) )
self.memory.subscribeToEvent(
Constants.EVENT,
self.naoqi_name,
self.on_word_recognised.func_name )
# Install global variables needed for Naoqi callbacks to work
def install_naoqi_globals(self):
globals()[self.naoqi_name] = self
globals()["memory"] = self.memory
def reconfigure(self, config):
self.proxy.setLanguage( config["language"] )
self.proxy.setAudioExpression( config["audio_expression"] )
self.proxy.setVisualExpression( config["visual_expression"] )
self.proxy.setVocabulary(
Util.parse_vocabulary( config["vocabulary"] ),
config["word_spotting"] )
def stop(self, module = None):
if module is None:
module = self.naoqi_name
rospy.loginfo("Unsubscribing '{}' from NAO speech recognition".format(
module))
try:
self.memory.unsubscribeToEvent( Constants.EVENT, module )
except RuntimeError:
rospy.logwarn("Could not unsubscribe from NAO speech recognition")
def on_word_recognised(self, key, value, subscriber_id ):
"""Publish the words recognized by NAO via ROS """
#Create dictionary, by grouping into tuples the list in value
temp_dict = dict( value[i:i+2] for i in range(0, len(value), 2) )
#Delete empty string from dictionary
if '' in temp_dict:
del(temp_dict[''])
self.pub.publish(WordRecognized( temp_dict.keys(), temp_dict.values() ))