00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 import roslib; roslib.load_manifest('sound_play')
00040 import rospy
00041 from sound_play.msg import SoundRequest
00042
00043 from sound_play.libsoundplay import SoundClient
00044
00045 def sleep(t):
00046 try:
00047 rospy.sleep(t)
00048 except:
00049 pass
00050
00051 if __name__ == '__main__':
00052 rospy.init_node('soundplay_test', anonymous = True)
00053 soundhandle = SoundClient()
00054
00055 rospy.sleep(1)
00056
00057 soundhandle.stopAll()
00058
00059 print "This script will run continuously until you hit CTRL+C, testing various sound_node sound types."
00060
00061 while not rospy.is_shutdown():
00062 print
00063 print 'Try to play wave files that do not exist.'
00064 soundhandle.playWave('17')
00065 soundhandle.playWave('dummy')
00066
00067 print 'say'
00068 soundhandle.say('Hello world!')
00069 sleep(3)
00070
00071 print 'wave (assumes you have some xemacs21 sounds present)'
00072 soundhandle.playWave('/usr/share/xemacs21/xemacs-packages/etc/sounds/cuckoo.wav')
00073
00074 sleep(3)
00075
00076 print 'wave2 (assumes you have some xemacs21 sounds present)'
00077 soundhandle.playWave('/usr/share/xemacs21/xemacs-packages/etc/sounds/say-beep.wav')
00078
00079 sleep(3)
00080
00081 print 'plugging'
00082 soundhandle.play(SoundRequest.NEEDS_PLUGGING)
00083 soundhandle.play(SoundRequest.NEEDS_PLUGGING)
00084
00085 sleep(2)
00086
00087
00088
00089 sleep(1)
00090
00091 print 'unplugging'
00092 soundhandle.play(SoundRequest.NEEDS_UNPLUGGING)
00093
00094 sleep(1)
00095 print 'plugging badly'
00096 soundhandle.play(SoundRequest.NEEDS_PLUGGING_BADLY)
00097 sleep(1)
00098
00099
00100 sleep(2)
00101 print 'unplugging badly'
00102 soundhandle.play(SoundRequest.NEEDS_UNPLUGGING_BADLY)
00103
00104 sleep(3)
00105
00106 s1 = soundhandle.builtinSound(SoundRequest.NEEDS_UNPLUGGING_BADLY)
00107 s2 = soundhandle.waveSound("/usr/share/xemacs21/xemacs-packages/etc/sounds/say-beep.wav")
00108 s3 = soundhandle.voiceSound("Testing the new A P I")
00109
00110 print "New API start voice"
00111 s3.repeat()
00112 sleep(2)
00113 print "New API wave"
00114 s2.play()
00115 sleep(2)
00116 print "New API builtin"
00117 s1.play()
00118 sleep(2)
00119 print "New API stop"
00120 s3.stop()