audio_transport.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Copyright: Yuki Furuta <furushchev@jsk.imi.i.u-tokyo.ac.jp>
4 
5 import rospy
6 import struct
7 from julius_ros.transport import SocketTransport
8 from audio_common_msgs.msg import AudioData
9 
10 
12  def __init__(self, host, port, max_retry, topic_name):
13  super(AudioTransport, self).__init__(host, port, max_retry)
14  self.topic_name = topic_name
15  self.sub_audio = None
16 
17  def start(self):
18  self.sub_audio = rospy.Subscriber(self.topic_name, AudioData, self.audio_cb)
19  super(AudioTransport, self).start()
20 
21  def join(self):
22  super(AudioTransport, self).join()
23  if self.sub_audio:
24  self.sub_audio.unregister()
25 
26  def audio_cb(self, msg):
27  header = struct.pack('i', len(msg.data))
28  self.send(header + msg.data)
def __init__(self, host, port, max_retry, topic_name)


julius_ros
Author(s): Yuki Furuta
autogenerated on Wed Jul 10 2019 03:47:05