class DialogflowService:
    def __init__(self):
        self._dc = DialogflowClient()
        self._service = rospy.Service('/dialogflow_client/intent_service', DialogflowService, self._service_cb)

    def _service_cb(self, req):
        if req.voice:
            df_msg = self._dc.detect_intent_stream()
        else:
            df_msg = self._dc.detect_intent_text(req.text)
        return DialogflowServiceResponse(success=True, result=df_msg)
 def start(self):
     # Register Ctrl-C sigint
     signal.signal(signal.SIGINT, self._signal_handler)
     # Setup snowboy
     self.detector = snowboydecoder.HotwordDetector(self.model_path,
                                                    sensitivity=[0.5, 0.5])
     self.df_client = DialogflowClient()
     rospy.loginfo("HOTWORD_CLIENT: Listening... Press Ctrl-C to stop.")
     while True:
         try:
             self.detector.start(detected_callback=self._df_callback,
                                 interrupt_check=self._interrupt_callback,
                                 sleep_time=0.03)
         except KeyboardInterrupt:
             self.exit()
 def __init__(self):
     self._dc = DialogflowClient()
     self._service = rospy.Service('/dialogflow_client/intent_service', DialogflowService, self._service_cb)
#!/usr/bin/env python

import rospy
from dialogflow_ros import DialogflowClient
from dialogflow_ros.msg import *

if __name__ == '__main__':
    rospy.init_node('test_intent_text', log_level=rospy.DEBUG)
    dc = DialogflowClient()
    dr = DialogflowRequest(query_text="what do you see")
    resp1 = dc.detect_intent_text(dr)
    # dr.query_text = "pick up the pencil"
    # dr.contexts = resp1.contexts
    # resp2 = dc.detect_intent_text(dr)
Esempio n. 5
0
#!/usr/bin/env python

import rospy
from dialogflow_ros import DialogflowClient
from dialogflow_ros.msg import *
from dialogflow_v2beta1.types import EventInput, QueryInput
from google.protobuf import struct_pb2
import datetime
if __name__ == '__main__':
    rospy.init_node('test_intent_text', log_level=rospy.DEBUG)
    dc = DialogflowClient()
    parameters = struct_pb2.Struct()
    hour = datetime.datetime.now().hour
    minute = datetime.datetime.now().minute
    parameters['time'] = "{}:{}".format(hour, minute)
    event_input = EventInput(name='GET_TIME',
                             parameters=parameters,
                             language_code=dc.get_language_code())
    print(dc.event_intent(event_input))
Esempio n. 6
0
#!/usr/bin/env python

import rospy
from dialogflow_ros import DialogflowClient
from dialogflow_ros_msgs.msg import *
from dialogflow.types import EventInput, QueryInput
from google.protobuf import struct_pb2
import datetime

if __name__ == '__main__':
    rospy.init_node('test_intent_text', log_level=rospy.DEBUG)
    dc = DialogflowClient()

    # parameters = struct_pb2.Struct()
    # hour = datetime.datetime.now().hour
    # minute = datetime.datetime.now().minute
    # parameters['time'] = "{}:{}".format(hour, minute)
    # event_input = EventInput(name='GET_TIME', parameters=parameters,
    #                          language_code=dc.get_language_code())
    # print(dc.event_intent(event_input))

    # parameters = struct_pb2.Struct()
    # parameters['objects'] = ['snack', 'milk']
    # event_input = EventInput(name='objects_found', parameters=parameters,
    #                          language_code=dc.get_language_code())

    event_name = 'objects_found'
    parameters = DialogflowParameter(param_name='objects',
                                     value=['snack', 'milk'])
    event_input = DialogflowEvent(event_name=event_name,
                                  parameters=[parameters])