Example #1
0
 def run(self):
   print "\r\nRobot is now ready to take commands."
   while True:
     try:
       voiceCommands = str(droid.recognizeSpeech().result)
     except:
       voiceCommands = ""
     print "Voice commands: %s" % voiceCommands
     self.callback(voiceCommands)
Example #2
0
 def run(self):
     print "\r\nRobot is now ready to take commands."
     while True:
         try:
             voiceCommands = str(droid.recognizeSpeech().result)
         except:
             voiceCommands = ""
         print "Voice commands: %s" % voiceCommands
         self.callback(voiceCommands)
Example #3
0
 def recognizeSpeech(self):
   """Launch the android cloud voice recognition framework and return
   the result."""
   droid.makeToast("Launching voice recognition")
   return str(droid.recognizeSpeech().result)
Example #4
0
 def recognizeSpeech(self):
     """Launch the android cloud voice recognition framework and return
 the result."""
     droid.makeToast("Launching voice recognition")
     return str(droid.recognizeSpeech().result)
Example #5
0
 def run(self):
   command = ''
   msg = ''
   while command != "Exit":
     try:
       command = utils.pickFromList(self.unlocked_droid,
           "Pick an action (set down phone to pause)",
           ['Say Hello', 'Point Using Compass', 'Take Picture',
            'Speak Location', 'Voice Command','Exit'])
     except KeyError as e:
       msg = "Sorry, please try that again. %s" % str(e)
       self.droid.makeToast(msg)
     else:
       # Pause sending commands so that robot only does what user selected here
       self.state.pauseSending = True
       if command == "Take Picture":
         self.remoteUplink.sendCmd(self.droid, "picture", True)
         self.droid.ttsSpeak("Asking robot to take a picture")
         self.droid.makeToast("Please wait, this may take a few seconds")
         time.sleep(5)
         msg = "Picture should be taken by now"
       elif command == "Speak Location":
         msg = "Speaking location"
         self.remoteUplink.sendCmd(self.droid, "x", True)
       elif command == "Voice Command":
         try:
           voiceCommand = droid.recognizeSpeech().result
           self.remoteUplink.sendCmd(self.droid, voiceCommand, True)
           msg = "Told the robot to " + voiceCommand
           self.droid.makeToast(msg)
           time.sleep(2)
         except:
           msg = "Could not understand"
       elif command == "Point Using Compass":
         msg = "This feature is currently not available on the robot."
         self.droid.makeToast(msg)
         # try:
         #   direction = utils.pickFromList(self.unlocked_droid,
         #       "Pick a direction", sorted([c for c in self.kCardinals]))
         # except KeyError as e:
         #   msg = "Sorry, please try that again. %s" % str(e)
         #   self.droid.makeToast(msg)
         # else:
         #   self.droid.ttsSpeak("Selected direction %s." % direction)
         #   cmd = "p " + self.kCardinals[direction]
         #  self.remoteUplink.sendCmd(self.droid, cmd, True)
         #  msg = "Asking robot to point " + direction
         #  self.droid.ttsSpeak(msg)
         #  time.sleep(2)
         #  msg = "Robot should be facing " + direction
       elif command == "Say Hello":
         msg = "Asking robot to say hello"
         self.remoteUplink.sendCmd(self.droid, "hi", True)
       elif command == "Exit":
         msg = "Bye bye. Come again."
         if self.sendQuit:
           self.remoteUplink.sendCmd(self.droid, "q", True)
     self.droid.ttsSpeak(msg)
     time.sleep(1)
     # This resumes sending of normal accelerometer stream of commands
     self.state.pauseSending = False
   self.remoteUplink.sendCmd(self.droid, "ws 0 0", True)
   # This will exit the main loop as well. Remove this if you only want to exit
   # the pop-up menu.
   self.state.running = False