-
Notifications
You must be signed in to change notification settings - Fork 2
tms_ur_speaker
Tomoya Itsuka edited this page Nov 12, 2019
·
2 revisions
This package is made for ros2_tms announce, SE, etc... It contains only one nodes.
- PC(or Raspi)
- Ubuntu18.04
- USB speaker
ros2 run tms_ur_speaker tms_ur_speaker_node
There are two services available.
This service can speech japanese text data,
ros2 service call speaker_srv tms_msg_ur.srv.SpeakerSrv '{"data": "こんにちは!"}'
and also play SE(local file). If you want to play local file, please set request.data "\<your_file_ path>".
ros2 service call speaker_srv tms_msg_ur.srv.SpeakerSrv '{"data": "\./wav/SE.wav"}'
This service can play wavefile from service request.data. Below is an example of a node that uses it.
class TestClientNode(Node):
...
async def play_wave(self, filename):
self.cli_speaker_wav = self.create_client(SpeakerWavSrv, 'speaker_wav_srv', callback_group=ReentrantCallbackGroup())
while not self.cli_speaker_wav.wait_for_service(1.0):
self.get_logger().info('service "speaker_wav_srv" not found...')
data = b''
with open(filename,mode='rb') as f:
data = f.read()
self.get_logger().info('send request')
req = SpeakerWavSrv.Request()
datas = list(bytearray(data))
for d in datas:
req.data.append(d.to_bytes(1,"little"))
await self.cli_speaker_wav.call_async(req)
self.get_logger().info('end service')
...