4 Simple example showing how to use the SoundClient provided by libsoundplay,
5 in blocking, non-blocking, and explicit usage.
10 from sound_play.msg
import SoundRequest
14 rospy.loginfo(
'Example: SoundClient play methods can take in an explicit'
15 ' blocking parameter')
19 sound_beep = soundhandle.waveSound(
"say-beep.wav", volume=0.5)
22 sound_beep.play(blocking=
True)
28 soundhandle.play(SoundRequest.NEEDS_UNPLUGGING, blocking=
True)
32 soundhandle.say(
'Say-ing stuff while block-ing')
33 soundhandle.say(
'Say-ing stuff without block-ing', blocking=
False)
39 Play various sounds, blocking until each is completed before going to the
42 rospy.loginfo(
'Example: Playing sounds in *blocking* mode.')
45 rospy.loginfo(
'Playing say-beep at full volume.')
46 soundhandle.playWave(
'say-beep.wav')
48 rospy.loginfo(
'Playing say-beep at volume 0.3.')
49 soundhandle.playWave(
'say-beep.wav', volume=0.3)
51 rospy.loginfo(
'Playing sound for NEEDS_PLUGGING.')
52 soundhandle.play(SoundRequest.NEEDS_PLUGGING)
54 rospy.loginfo(
'Speaking some long string.')
55 soundhandle.say(
'It was the best of times, it was the worst of times.')
60 Play the same sounds with manual pauses between them.
62 rospy.loginfo(
'Example: Playing sounds in *non-blocking* mode.')
69 rospy.loginfo(
'Playing say-beep at full volume.')
70 soundhandle.playWave(
'say-beep.wav')
73 rospy.loginfo(
'Playing say-beep at volume 0.3.')
74 soundhandle.playWave(
'say-beep.wav', volume=0.3)
77 rospy.loginfo(
'Playing sound for NEEDS_PLUGGING.')
78 soundhandle.play(SoundRequest.NEEDS_PLUGGING)
81 rospy.loginfo(
'Speaking some long string.')
82 soundhandle.say(
'It was the best of times, it was the worst of times.')
86 if __name__ ==
'__main__':
87 rospy.init_node(
'soundclient_example', anonymous=
False)
91 rospy.loginfo(
'Finished')