Go to the documentation of this file.00001
00002
00003
00004
00005 import rospy
00006 import struct
00007 from julius_ros.transport import SocketTransport
00008 from audio_common_msgs.msg import AudioData
00009
00010
00011 class AudioTransport(SocketTransport):
00012 def __init__(self, host, port, max_retry, topic_name):
00013 super(AudioTransport, self).__init__(host, port, max_retry)
00014 self.topic_name = topic_name
00015 self.sub_audio = None
00016
00017 def start(self):
00018 self.sub_audio = rospy.Subscriber(self.topic_name, AudioData, self.audio_cb)
00019 super(AudioTransport, self).start()
00020
00021 def join(self):
00022 super(AudioTransport, self).join()
00023 if self.sub_audio:
00024 self.sub_audio.unregister()
00025
00026 def audio_cb(self, msg):
00027 header = struct.pack('i', len(msg.data))
00028 self.send(header + msg.data)