本文整理汇总了Python中naoqi.ALProxy.setLanguage方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.setLanguage方法的具体用法?Python ALProxy.setLanguage怎么用?Python ALProxy.setLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.setLanguage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FaceDetectionModule
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
class FaceDetectionModule(ALModule):
# Déclaration de méthode.
def __init__(self, name):
ALModule.__init__(self, name)
print "[INFO ] FaceDetectionModule initialization"
# Instanciation d'un objet tts de classe ALTextToSpeech.
self.tts = ALProxy("ALTextToSpeech")
self.tts.setLanguage("french")
# Instanciation d'un objet tts de classe ALFaceDetection.
self.fd = ALProxy("ALFaceDetection")
# Variable d'instance.
global memory
# Instanciation d'un objet memory de classe ALMemory.
memory = ALProxy("ALMemory")
# Appel de la methode subsribeToEvent...
memory.subscribeToEvent("FaceDetected", # Sur cet evenement...
"FaceDetection", # ...de cet instance...
"onDetection") # ...declancher l'appel
# ...de cette methode.
print "[INFO ] FaceDetectionModule initialized"
# Méthode appelée sur l'évènement.
def onDetection(self, *_args):
print "[INFO ] FaceDetection: Face detected"
global face_nb
print "[INFO ] FaceDetection initialize face detection process"
learnFaceProcess(self, face_nb)
示例2: SpeechDetectionModule
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
class SpeechDetectionModule(ALModule):
""" A module that handles NAO recognition app commands. """
def __init__(self, name):
ALModule.__init__(self, name)
self.name = name
self.memory = ALProxy("ALMemory")
self.asr = ALProxy("ALSpeechRecognition")
self.asr.setLanguage("English")
vocabulary = ["color", "text", "gesture", "phone"]
self.asr.setVocabulary(vocabulary, False)
self.asr.subscribe(self.getName())
self.memory.subscribeToEvent("WordRecognized", self.getName(), "onWordRecognized")
def onWordRecognized(self, key, value, message):
""" A method that handles command recognition. """
global NaoWorkingMode
if(len(value) > 1 and value[1] >= 0.5):
print 'recognized the word :', value[0]
NaoWorkingMode = value[0]
else:
print 'unsifficient threshold'
NaoWorkingMode = None
def disconnect(self):
try:
self.memory.unsubscribeToEvent("WordRecognized", self.getName())
self.asr.unsubscribe(self.getName())
except BaseException, err:
print "Error while disconnecting from speech module: " + str(err)
示例3: NAOVoiceRec
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [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)
示例4: start
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
def start(self):
if self.al.connected():
self.tts.say("You are already connected")
else:
self.networks = self.al.list_networks()
self.tts.say("Here are the Wi Fi networks")
for num, network in enumerate(self.networks, 1):
self.tts.say(network)
self.tts.say("is number %d" % (num,))
time.sleep(0.2)
if len(self.networks) == 0:
self.tts.say("Sorry you are in a wifi free zone")
else:
self.tts.say("Which number Wi Fi network shall I connect to?")
try:
self.memory.unsubscribeToEvent("WordRecognized")
except Exception:
pass
speech_recognition = ALProxy("ALSpeechRecognition", NAO_IP, 9559)
speech_recognition.setLanguage("English")
try:
speech_recognition.setWordListAsVocabulary([str(i) for i in range(1, len(self.networks))])
except Exception:
self.tts.say("Could not set vocabulary")
try:
result = self.memory.subscribeToEvent("WordRecognized", self.module_name, "on_word_recognised")
print "Subscribed to event WordRecognized with package ", self.module_name, " and result ", result
except Exception as e:
print "Failed to subscribe ", e
示例5: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [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
# HUE service
self._hue = None
self._teller = None
# Create a proxy to ALTextToSpeech for later use
global tts
tts = ALProxy("ALTextToSpeech", NAO_IP, 9559)
# Subscribe to the FaceDetected event:
global memory
self.leds = ALProxy("ALLeds", NAO_IP, 9559)
memory = ALProxy("ALMemory")
memory.subscribeToEvent("MiddleTactilTouched",
"HumanGreeter",
"onMiddleTouchSensed")
# memory.unsubscribeToEvent("WordRecognized",
# "HumanGreeter")
speechrecog = ALProxy("ALSpeechRecognition")
speechrecog.setLanguage("French")
wordList = ["bleu", "rouge", "vert", "jaune",
"porte", "température", "meteo"]
try:
speechrecog.setVocabulary(wordList, True)
except Exception as ex:
_logger.warning("Got exception: %s", ex)
tts.say("Je suis prêt à recevoir des ordres")
示例6: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
class Nao:
def __init__(self,ip,port):
self.tts = ALProxy("ALTextToSpeech", ip, port)
self.motion = ALProxy("ALMotion", ip, port)
self.posture = ALProxy("ALRobotPosture", ip, port)
self.memory = ALProxy("ALMemory")
self.speech = ALProxy("ALSpeechRecognition",ip,port)
#Word Recognition
self.speech.setLanguage("English")
wordList=["hello","goodbye","yes","no", "exit", "sit down"]
self.speech.setWordListAsVocabulary(wordList)
self.memory.subscribeToEvent("WordRecognized","pythonModule", "onSpeechRecognized") # event is case sensitive !
def sit_down(self):
self.posture.goToPosture("Sit", 0.3)
time.sleep(0.5)
self.motion.setStiffnesses("Body", 0.3)
fractionMaxSpeed=0.1
self.motion.setAngles(["LArm"],[ 0.96, 0.03,-0.71,-1.20, 0.00, 0.30],fractionMaxSpeed)
self.motion.setAngles(["RArm"],[ 0.96,-0.05, 0.71, 1.20, 0.00, 0.30],fractionMaxSpeed)
self.motion.setAngles(["RLeg"],[-0.84,-0.30,-1.50, 1.02, 0.92, 0.00],fractionMaxSpeed)
self.motion.setAngles(["LLeg"],[-0.84, 0.30,-1.50, 1.02, 0.92, 0.00],fractionMaxSpeed)
time.sleep(0.5)
self.motion.setStiffnesses("Body", 0.0)
time.sleep(0.25)
def __del__(self):
print "memory.unsubscribeToEvent(WordRecognized,pythonModule)"
self.memory.unsubscribeToEvent("WordRecognized","pythonModule") # event is case sensitive !
示例7: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
class Nao:
def __init__(self,ip,port):
self.tts = ALProxy("ALTextToSpeech", ip, port)
self.motion = ALProxy("ALMotion", ip, port)
self.posture = ALProxy("ALRobotPosture", ip, port)
self.memory = ALProxy("ALMemory")
self.speech = ALProxy("ALSpeechRecognition",ip,port)
#Word Recognition
self.speech.setLanguage("English")
wordList=["hello","goodbye","yes","no", "exit", "sit down"]
pythonModule.WordDetection(wordList)
def sit_down(self):
self.posture.goToPosture("Sit", 0.3)
time.sleep(0.5)
self.motion.setStiffnesses("Body", 0.3)
fractionMaxSpeed=0.1
self.motion.setAngles(["LArm"],[ 0.96, 0.03,-0.71,-1.20, 0.00, 0.30],fractionMaxSpeed)
self.motion.setAngles(["RArm"],[ 0.96,-0.05, 0.71, 1.20, 0.00, 0.30],fractionMaxSpeed)
self.motion.setAngles(["RLeg"],[-0.84,-0.30,-1.50, 1.02, 0.92, 0.00],fractionMaxSpeed)
self.motion.setAngles(["LLeg"],[-0.84, 0.30,-1.50, 1.02, 0.92, 0.00],fractionMaxSpeed)
time.sleep(0.5)
self.motion.setStiffnesses("Body", 0.0)
time.sleep(0.25)
def __del__(self):
示例8: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
def main():
parser = OptionParser(usage="Usage: %prog [options] [phrase1 [phrase2 ...]]")
parser.add_option("-v", "--volume",
action="store", type="int", dest="volume",
help=u"définir le volume", metavar="VOL")
(options, args) = parser.parse_args()
if (options.volume):
vol = ALProxy("ALAudioDevice", IP, PORT)
vol.setOutputVolume(min(max(options.volume, 0), 100))
tts = ALProxy("ALTextToSpeech", IP, PORT)
tts.setLanguage('French')
if len(args) == 0:
line = 1
while line:
try:
line = stdin.readline().strip('\n')
except KeyboardInterrupt:
break
if line:
say(tts, line)
else:
for arg in args:
say(tts, arg)
示例9: exe
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
def exe(self, args=None, addr=None):
# get proxies
tts = ALProxy("ALTextToSpeech", Settings.naoHostName, Settings.naoPort)
# set system volume
if len(args) > 0:
tts.setLanguage( str(args[0]) )
示例10: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
def main():
""" Main entry point
"""
parser = OptionParser()
parser.add_option("--pip",
help="Parent broker port. The IP address or your robot",
dest="pip")
parser.add_option("--pport",
help="Parent broker port. The port NAOqi is listening to",
dest="pport",
type="int")
parser.set_defaults(
pip="10.0.1.3",
pport=9559)
(opts, args_) = parser.parse_args()
pip = opts.pip
pport = opts.pport
# We need this broker to be able to construct
# NAOqi modules and subscribe to other modules
# The broker must stay alive until the program exists
myBroker = ALBroker("myBroker",
"0.0.0.0", # listen to anyone
0, # find a free port and use it
pip, # parent broker IP
pport) # parent broker port
asr = ALProxy("ALSpeechRecognition", "10.0.1.3", 9559)
asr.setLanguage("English")
# Example: Adds "yes", "no" and "please" to the vocabulary (without wordspotting)
vocabulary = ["yes", "no", "please"]
asr.setVocabulary(vocabulary, False)
# Start the speech recognition engine with user Test_ASR
asr.subscribe("Test_ASR")
# Warning: HumanGreeter must be a global variable
# The name given to the constructor must be the name of the
# variable
global SpeechDetector
SpeechDetector = SpeechDetectorModule("SpeechDetector")
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print
print "Interrupted by user, shutting down"
asr.unsubscribe("Test_ASR")
myBroker.shutdown()
sys.exit(0)
示例11: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
def main(robot_ip, robot_port, topf_path):
# creates the speech recognition proxy and a csv file
createSpeechRecogProxy(robot_ip, robot_port)
createFile(csvf)
# creates dialog and posture proxies
dialog_p = ALProxy('ALDialog', robot_ip, robot_port)
postureProxy = ALProxy("ALRobotPosture", robot_ip, robot_port)
dialog_p.setLanguage("English")
postureProxy.goToPosture("StandInit", 0.5) # brings robot to standing pos.
# Load topic - absolute path is required
# TOPIC MUST BE ON ROBOT
topic = dialog_p.loadTopic(topf_path)
# Start dialog
dialog_p.subscribe('myModule')
# Activate dialog
dialog_p.activateTopic(topic)
# create broker
myBroker = ALBroker("myBroker", "0.0.0.0",
0, robot_ip, robot_port)
# creates a module called "Move"
global Move
Move = TestModule("Move")
# pressing key will unsubscribe from the topic
raw_input(u"Press 'Enter to exit.")
asr.unsubscribe("Test_ASR")
# until interrupted, keep broker running
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print
print "Interrupted by user, shutting down"
myBroker.shutdown()
# Deactivate topic
dialog_p.deactivateTopic(topic)
# Unload topic
dialog_p.unloadTopic(topic)
# Stop dialog
dialog_p.unsubscribe('myModule')
# close file
f.close()
# exit
sys.exit(0)
示例12: startRecognizing
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
def startRecognizing(self):
global asr
asr = ALProxy("ALSpeechRecognition")
asr.setLanguage("English")
# wordList = ["go forward", "turn left", "turn right", "stop"]
# asr.setVocabulary(wordList, True)
global Recognizer
Recognizer = RecognizerModule("Recognizer")
示例13: createSpeechRecogProxy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
def createSpeechRecogProxy(robot_ip, robot_port):
# creates the speech recognition proxy
global asr
asr = ALProxy("ALSpeechRecognition", robot_ip, robot_port)
asr.setLanguage("English")
asr.pause(True)
# adds vocabulary, sets it, and enables word spotting
vocabulary = ["what is the slope of the line from"]
asr.setVocabulary(vocabulary, True)
asr.pause(False)
asr.subscribe("Test_ASR")
示例14: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
def __init__(self, handle, ip, port):
ALModule.__init__(self, handle)
self._handle = handle
self._ip = ip
self._port = port
tts = ALProxy('ALTextToSpeech', ip, port)
tts.setLanguage('English')
self._tts = tts
aup = ALProxy('ALAudioPlayer', ip, port)
self._aup = aup
示例15: shuo
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setLanguage [as 别名]
class shuo(threading.Thread):
IP = ""
def __init__(self, robotIP):
self.IP = robotIP
threading.Thread.__init__(self)
self.audio = ALProxy("ALTextToSpeech", self.IP, 9559)
def run(self):
self.audio.setLanguage("Chinese")
self.audio.say("加油")
# time.time(0.5)
self.audio.say("我相信你可以的!")