Skip to content

Commit

Permalink
Merge pull request ros-drivers#174 from iory/cache
Browse files Browse the repository at this point in the history
Add arg2 information for cache
  • Loading branch information
knorth55 authored Aug 13, 2021
2 parents 75a126e + 659abfe commit 89140f1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions sound_play/scripts/soundplay_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@ def select_sound(self, data):
sound = self.filesounds[absfilename]
elif data.sound == SoundRequest.SAY:
# print data
if not data.arg in self.voicesounds.keys():
rospy.logdebug('command for uncached text: "%s"' % data.arg)
voice_key = data.arg + '---' + data.arg2
if not voice_key in self.voicesounds.keys():
rospy.logdebug('command for uncached text: "%s"' % voice_key)
txtfile = tempfile.NamedTemporaryFile(prefix='sound_play', suffix='.txt')
(wavfile,wavfilename) = tempfile.mkstemp(prefix='sound_play', suffix='.wav')
txtfilename=txtfile.name
Expand All @@ -271,15 +272,15 @@ def select_sound(self, data):
except OSError:
rospy.logerr('Sound synthesis failed. Is festival installed? Is a festival voice installed? Try running "rosdep satisfy sound_play|sh". Refer to http://wiki.ros.org/sound_play/Troubleshooting')
return
self.voicesounds[data.arg] = soundtype(wavfilename, self.device, data.volume)
self.voicesounds[voice_key] = soundtype(wavfilename, self.device, data.volume)
finally:
txtfile.close()
else:
rospy.logdebug('command for cached text: "%s"'%data.arg)
if self.voicesounds[data.arg].sound.get_property('volume') != data.volume:
rospy.logdebug('command for cached text: "%s"' % voice_key)
if self.voicesounds[voice_key].sound.get_property('volume') != data.volume:
rospy.logdebug('volume for cached text has changed, resetting volume')
self.voicesounds[data.arg].sound.set_property('volume', data.volume)
sound = self.voicesounds[data.arg]
self.voicesounds[voice_key].sound.set_property('volume', data.volume)
sound = self.voicesounds[voice_key]
else:
rospy.logdebug('command for builtin wave: %i'%data.sound)
if data.sound not in self.builtinsounds or (data.sound in self.builtinsounds and data.volume != self.builtinsounds[data.sound].volume):
Expand Down

0 comments on commit 89140f1

Please sign in to comment.