detect_intent_service.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 from dialogflow_ros.srv import DialogflowService
5 from dialogflow_ros import DialogflowClient
6 
7 
9  def __init__(self):
10  self._dc = DialogflowClient()
11  self._service = rospy.Service('/dialogflow_client/intent_service', DialogflowService, self._service_cb)
12 
13  def _service_cb(self, req):
14  if req.voice:
15  df_msg = self._dc.detect_intent_stream()
16  else:
17  df_msg = self._dc.detect_intent_text(req.text)
18  return DialogflowServiceResponse(success=True, result=df_msg)
19 
20 
21 if __name__ == '__main__':
22  rospy.init_node('dialogflow_service')
24  rospy.loginfo("DF_CLIENT: Dialogflow Service is running...")
25  rospy.spin()


dialogflow_ros
Author(s): Anas Abou Allaban
autogenerated on Mon Jun 10 2019 13:02:59