4 from snowboy
import snowboydecoder
6 from dialogflow_ros
import DialogflowClient
9 from rospkg.rospack
import RosPack
23 pkg_path = rpack.get_path(
'dialogflow_ros')
24 self.
model_path = pkg_path +
'/scripts/snowboy/resources/jarvis.umdl' 25 ding_path = pkg_path +
'/scripts/snowboy/resources/ding.wav' 29 ding = wave.open(ding_path,
'rb')
33 format=self.audio.get_format_from_width(ding.getsampwidth()),
34 channels=ding.getnchannels(), rate=ding.getframerate(),
35 input=
False, output=
True)
37 rospy.loginfo(
"HOTWORD_CLIENT: Ready!")
40 rospy.logwarn(
"SIGINT Caught!")
47 """Simple function to play a Ding sound.""" 48 self.stream_out.start_stream()
51 self.stream_out.stop_stream()
54 rospy.loginfo(
"HOTWORD_CLIENT: Hotword detected!")
57 df_msg, res = self.df_client.detect_intent_stream(return_result=
True)
65 sensitivity=[0.5, 0.5])
67 rospy.loginfo(
"HOTWORD_CLIENT: Listening... Press Ctrl-C to stop.")
73 except KeyboardInterrupt:
79 self.stream_out.close()
80 self.audio.terminate()
81 self.detector.terminate()
85 if __name__ ==
'__main__':
86 rospy.init_node(
'hotword_client', log_level=rospy.DEBUG)
def _signal_handler(self, signal, frame)
def _interrupt_callback(self)