Пример #1
2
  def startAudioRecording(self, fileName):
    """Starts recording audio.

    Args:
      fileName -- file to use to save stored audio
    """
    droid.makeToast("Starting audio recording")
    droid.recorderStartMicrophone(fileName)
Пример #2
0
    def startAudioRecording(self, fileName):
        """Starts recording audio.

    Args:
      fileName -- file to use to save stored audio
    """
        droid.makeToast("Starting audio recording")
        droid.recorderStartMicrophone(fileName)
Пример #3
0
 def specialToast(self, droid, msg):
   try:
     # Don't toast the same message repeatedly unless 5 seconds have passed
     if msg != self.previousToastMsg or \
        (time.time() > self.lastToastMsgTime + 5000):
       droid.makeToast(msg)
   except:
     pass
   self.previousToastMsg=msg
   self.lastToastMsgTime = time.time()
Пример #4
0
  def speak(self, speech, override=False):
    """Outputs talk.

    Args:
    speech -- string of characters for android speech
    override -- set to true to override the audioOn state
    """
    # TODO: Move the muted state (audioOn) out of the config object.
    if (self.config.audioOn and speech != self.previousMsg) or override:
      droid.ttsSpeak(speech)
    elif speech != self.previousMsg:
      droid.makeToast(speech)
    self.previousMsg = speech
Пример #5
0
    def speak(self, speech, override=False):
        """Outputs talk.

    Args:
    speech -- string of characters for android speech
    override -- set to true to override the audioOn state
    """
        # TODO: Move the muted state (audioOn) out of the config object.
        if (self.config.audioOn and speech != self.previousMsg) or override:
            droid.ttsSpeak(speech)
        elif speech != self.previousMsg:
            droid.makeToast(speech)
        self.previousMsg = speech
Пример #6
0
def uplinkFactory(config):
    """Consult the configuration to determine which uplink to
  instantiate, and return it

  Args:
    config -- global configuration object

  Returns:
    uplink -- configured uplink instance required to talk to the cloud
  """
    if config.inputMethod == "commandByJSON":
        print "Initiating input by JSON"
        droid.makeToast("Initiating input by JSON")
        uplink = commandByJSON(config.msgRelayUrl)
    elif config.inputMethod == "commandByXMPP":
        print "Initiating input by XMPP"
        droid.makeToast("Initiating input by XMPP")
        if config.mode == config.kModeRobot:
            uplink = commandByXMPP(config.xmppServer, config.xmppPort,
                                   config.xmppRobotUsername,
                                   config.xmppRobotPassword, None)
        elif config.mode == config.kModeRemote:
            uplink = commandByXMPP(config.xmppServer, config.xmppPort,
                                   config.xmppRemoteUsername,
                                   config.xmppRemoteUserPassword,
                                   config.xmppRobotUsername)
    elif config.inputMethod == "commandByTelnet":
        print "Initiating input by telnet"
        droid.makeToast("Initiating input by telnet")
        if config.mode == config.kModeRemote:
            phoneIP = config.robotHost
        else:
            phoneIP = config.phoneIP
        uplink = commandByTelnet(phoneIP, config.telnetPort,
                                 config.mode == config.kModeRobot)
    elif config.inputMethod == "commandByVoice":
        print "Initiating input by voice"
        droid.makeToast("Initiating input by voice")
        uplink = commandByVoice()
    elif (config.inputMethod == "commandBySelf"):
        print "Initiating input by self remote"
        droid.makeToast("Initiating input by self remote")
        uplink = commandBySelf()
    else:
        raise UplinkError("Uplink type unrecognized: '%s'" %
                          config.inputMethod)
    return uplink
Пример #7
0
def uplinkFactory(config):
  """Consult the configuration to determine which uplink to
  instantiate, and return it

  Args:
    config -- global configuration object

  Returns:
    uplink -- configured uplink instance required to talk to the cloud
  """
  if config.inputMethod == "commandByJSON":
    print "Initiating input by JSON"
    droid.makeToast("Initiating input by JSON")
    uplink = commandByJSON(config.msgRelayUrl)
  elif config.inputMethod == "commandByXMPP":
    print "Initiating input by XMPP"
    droid.makeToast("Initiating input by XMPP")
    if config.mode == config.kModeRobot:
      uplink = commandByXMPP(
          config.xmppServer, config.xmppPort, config.xmppRobotUsername,
          config.xmppRobotPassword, None)
    elif config.mode == config.kModeRemote:
      uplink = commandByXMPP(
          config.xmppServer, config.xmppPort, config.xmppRemoteUsername,
          config.xmppRemoteUserPassword, config.xmppRobotUsername)
  elif config.inputMethod == "commandByTelnet":
    print "Initiating input by telnet"
    droid.makeToast("Initiating input by telnet")
    if config.mode == config.kModeRemote:
      phoneIP = config.robotHost
    else:
      phoneIP = config.phoneIP
    uplink = commandByTelnet(phoneIP, config.telnetPort,
                             config.mode == config.kModeRobot)
  elif config.inputMethod == "commandByVoice":
    print "Initiating input by voice"
    droid.makeToast("Initiating input by voice")
    uplink = commandByVoice()
  elif (config.inputMethod =="commandBySelf"):
    print "Initiating input by self remote"
    droid.makeToast("Initiating input by self remote")
    uplink = commandBySelf()
  else:
    raise UplinkError("Uplink type unrecognized: '%s'" % config.inputMethod)
  return uplink
Пример #8
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)
Пример #9
0
 def stopAudioRecording(self):
   """Stops recording audio."""
   droid.makeToast("Stopping audio recording")
   droid.recorderStop()
Пример #10
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)
Пример #11
0
 def stopAudioRecording(self):
     """Stops recording audio."""
     droid.makeToast("Stopping audio recording")
     droid.recorderStop()