コード例 #1
0
ファイル: mockbot.py プロジェクト: sunarditay/tue_robocup
    def recognize(self, spec, choices, time_out=None):
        answer = GetSpeechResponse(result="Mockbot cannot actually hear, this is a dummy answer")
        keys = choices.keys()
        if "prefix" in keys:
            keys.remove("prefix")

        for key in keys:
            answer.choices += [Choice(id=key, values=[random.choice(choices[key])])]

        answer.choices = dict((x.id, x.values[0]) for x in answer.choices)

        return answer
コード例 #2
0
    def srv_callback(self, req):
        spec = req.spec
        choices = dict((x.id, x.values) for x in req.choices)
        time_out = req.time_out.to_sec()

        rospy.loginfo("Speech specification: [%s]"%cyan(spec))

        # RPC request to vbox
        result = self.sp.recognize(spec, choices, time_out)
        if result:
            result["choices"] = [ Choice(id=k, values=[v]) for k, v in result["choices"].iteritems() ]
            rospy.loginfo("Speech result: [%s]"%cyan(result["result"]))
        else:
            rospy.loginfo("Speech result: [%s]"%cyan("None"))

        return result
コード例 #3
0
    def recognize(self, spec, choices={}, time_out=rospy.Duration(10)):
        req = GetSpeechRequest()
        req.spec = spec
        req.choices = [Choice(id=k, values=v) for k, v in choices.iteritems()]
        req.time_out = time_out

        answer = None

        try:
            answer = self.get_speech_client_service(req)
            if answer:
                answer.choices = dict(
                    (x.id, x.values[0]) for x in answer.choices)
        except rospy.ServiceException as e:
            rospy.logerr("Service exception: %s" % e)

        return answer
コード例 #4
0
ファイル: mockbot.py プロジェクト: Aand1/tue_robocup
 def __init__(self, *args, **kwargs):
     answer = GetSpeechResponse(
         result="I will go to the desk in the kitchen")
     answer.choices += [Choice(id="room", values=["kitchen"])]
     answer.choices += [Choice(id="table", values=["desk"])]