当前位置: 首页>>代码示例>>Python>>正文


Python SoundClient.stopAll方法代码示例

本文整理汇总了Python中sound_play.libsoundplay.SoundClient.stopAll方法的典型用法代码示例。如果您正苦于以下问题:Python SoundClient.stopAll方法的具体用法?Python SoundClient.stopAll怎么用?Python SoundClient.stopAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sound_play.libsoundplay.SoundClient的用法示例。


在下文中一共展示了SoundClient.stopAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class MainLoop:
  def __init__(self):
    self.voice = rospy.get_param("~voice", "voice_don_diphone")
    self.soundhandle = SoundClient()
    rospy.sleep(1)
    self.soundhandle.stopAll()
    rospy.sleep(1)
    self.soundhandle.say("Ready", self.voice)
    rospy.sleep(1)
    pub = rospy.Publisher('cmd_vel', Twist)
    rospy.sleep(1)
    # Create sound client
    self.words=SoundClient()
    # Subscribe to the /recognizer/output topic to receive voice commands.  
    rospy.Subscriber('/recognizer/output', String, MicInputEventCallback)
    # Subscribe to the /mobile_base/events/digital_input topic to receive DIO
    rospy.Subscriber('/mobile_base/events/digital_input', DigitalInputEvent, DigitalInputEventCallback)
    rospy.sleep(1)
    
    twist=Twist()
    pub=rospy.Publisher('cmd_vel',Twist)
    
  def talk(self, words):
    self.soundhandle.say(words, self.voice)
    rospy.sleep(1)
开发者ID:amuaz2,项目名称:kamerider,代码行数:27,代码来源:follow_me4.py

示例2: callback

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
 def callback(self, msg):
     if msg.min_distance < 2.0:
         soundhandle = SoundClient()
         rospy.sleep(rospy.Duration(1))
         soundhandle.playWave(self.sound)
         rospy.sleep(rospy.Duration(2))
         soundhandle.stopAll()
开发者ID:cdondrup,项目名称:christmas,代码行数:9,代码来源:santa.py

示例3: __init__

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class TalkBack:
    def __init__(self, script_path):
        rospy.init_node('talkback')

        rospy.on_shutdown(self.cleanup)
        self.voice = rospy.get_param("~voice", "voice_don_diphone")
        self.wavepath = rospy.get_param("~wavepath", script_path + "/../sounds")
        self.soundhandle = SoundClient()
        rospy.sleep(1)
        self.soundhandle.stopAll()
        self.soundhandle.playWave(self.wavepath + "/R2D2a.wav")
        rospy.sleep(1)
        self.soundhandle.say("Ready", self.voice)
        rospy.loginfo("Say one of the navigation commands...")
        rospy.Subscriber('/recognizer/output', String, self.talkback)
        
    def talkback(self, msg):
	palabra = msg.data
        rospy.loginfo(palabra)
	if (palabra == "cancel"):
		rospy.loginfo("The number is one")
        self.soundhandle.say(msg.data, self.voice)

    def cleanup(self):
        self.soundhandle.stopAll()
        rospy.loginfo("Shutting down talkback node...")
开发者ID:Ortega-R94,项目名称:donaxi_arm_2,代码行数:28,代码来源:numbers.py

示例4: __init__

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class VoiceGenerator:
    def __init__(self):
        rospy.on_shutdown(self.cleanup)

        #self.voice = rospy.get_param("~voice", "voice_kal_diphone")
        self.voice = rospy.get_param("~voice", "voice_don_diphone")
        self.wavepath = rospy.get_param("~wavepath", "")
        self.topic = rospy.get_param("~voice_topic", "")
       
        # Create the sound client object
        self.soundhandle = SoundClient()
        
        rospy.sleep(1)
        self.soundhandle.stopAll()
       
        # Announce that we are ready for input
        rospy.sleep(1)
        self.soundhandle.say("Voice Module Ready", self.voice)

        rospy.loginfo("Message ...")

        # Subscribe to the recognizer output
        rospy.Subscriber(self.topic, String, self.voicegenerator)
    
    def switch_asr_onoff_client(self, x):
        rospy.wait_for_service('switch_asr_on_off')
        try:
            switch_asr_on_off = rospy.ServiceProxy('switch_asr_on_off', asr_status)
            resp1 = switch_asr_on_off(x)
            
        except rospy.ServiceException, e:
            print "Service call failed: %s"%e
开发者ID:Robotica-ule,项目名称:MYRABot,代码行数:34,代码来源:voice_component.py

示例5: __init__

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class voice_play:

    def __init__(self):
        self.voice = rospy.get_param("~voice", "voice_cmu_us_clb_arctic_clunits")
        self.sound_files_dir = rospy.get_param("~sound_dir", "")

        self.sound_handle = SoundClient()

        rospy.sleep(1)
        rospy.loginfo("Ready to speak...")

        rospy.Subscriber('/speech', String, self.talkback)
        rospy.Subscriber('/sounds', String, self.play_sound)
        # self.sound_handle.say('Greetings, I am Judith.', self.voice)

    def talkback(self, msg):
        rospy.loginfo(msg.data)
        self.sound_handle.stopAll()
        self.sound_handle.say(msg.data, self.voice)
        rospy.sleep(2)

    def play_sound(self, msg):
        rospy.loginfo(msg.data)
        self.sound_handle.stopAll()
        self.sound_handle.playWave(self.sound_files_dir + msg.data)
        rospy.sleep(2)
开发者ID:OpenFEI,项目名称:rfh_judite,代码行数:28,代码来源:voice_play.py

示例6: __init__

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class Hello:
    """ 
    a class to greet people need to recognise people 
    """
    def __init__(self):
        self.voice = rospy.get_param("~voice", "voice_en1_mbrola")
        # Create the sound client object
        self.soundhandle = SoundClient()
        
        # Wait a moment to let the client connect to the
        # sound_play server
        rospy.sleep(1)
        
        # Make sure any lingering sound_play processes are stopped.
        self.soundhandle.stopAll()

        #set action server
        self.client = SimpleActionClient('face_recognition', face_recognition.msg.FaceRecognitionAction)

        # listening for goals.
        self.client.wait_for_server()
        rospy.sleep(2)

        #result will be published on this topic
        rospy.Subscriber("/face_recognition/result", FaceRecognitionActionFeedback, self.face_found)
        rospy.Subscriber("/face_recognition/feedback", FaceRecognitionActionFeedback, self.Unknown)
        self.look_for_face()
    def look_for_face(self):
        '''
        send command look for face once
        '''
        goal = face_recognition.msg.FaceRecognitionGoal(order_id=0, order_argument="none")
        self.client.send_goal(goal)
        #self.client.wait_for_result(rospy.Duration.from_sec(6.0))
        #if self.client.get_state() == GoalStatus.FAILED:
            #self.unknown()

    def face_found(self,msg):
        '''
        clean up feedback to extract the name
        check if greeted before answer accordingly
        '''
        

        person = str(msg.result.names[0])
        rospy.logwarn(person)
        
        self.soundhandle.say("hello   "+ person ,self.voice)
        #self.task1 = "hello" + person
        #rospy.sleep(2)
        #return the processed value
        self.value = str(self.task1)

    def Unknown(self,msg):
        self.soundhandle.say("hello     what is your name   " ,self.voice)

    def __str__(self):
        return 
开发者ID:Aharobot,项目名称:inmoov_ros,代码行数:60,代码来源:interaction.py

示例7: execute

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
    def execute(self, userdata):

        soundhandle = SoundClient()
        #let ROS get started...
        rospy.sleep(0.5)

        soundhandle.stopAll()

        return succeeded
开发者ID:jypuigbo,项目名称:robocup-code,代码行数:11,代码来源:play_sound_sm.py

示例8: TtsServer

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class TtsServer(object):
	feedback = TtsFeedback()
	result = TtsResult()

	def __init__(self, name):
		self._action_name = name
		self._as = actionlib.SimpleActionServer(self._action_name, TtsAction, self.execute_cb, auto_start = False)
		self._as.start()
		self.client = SoundClient()
		rospy.sleep(1)
		self.client.stopAll()
		rospy.loginfo("Started ActionServer")

	def execute_cb(self, goal):
		self.feedback.event_type = 1
		self.feedback.timestamp = rospy.get_rostime()
		self._as.publish_feedback(self.feedback)

		goalString = goal.rawtext.text

		self.result.text = goalString
		self.result.msg = "This string can be used to display an eventual error or warning message during voice synthesis"
		
		rospy.sleep(goal.wait_before_speaking)
		
		# self.client.say(goalString)
		words = goalString.split()
		self.sayWords(words)

		self._as.set_succeeded(self.result)
	
		self.feedback.event_type = 2
		self.feedback.timestamp = rospy.get_rostime()
		self._as.publish_feedback(self.feedback)

	def sayWords(self, words):
		i = 0
		self.feedback.event_type = 32

		for word in words:
			self.client.say(word)
			self.feedback.text_said = word

			if(i<len(words)-1):
				self.feedback.next_word = words[i+1]
			else:
				self.feedback.next_word = "Reached the end of the sentence"
				self.feedback.event_type = 128

			self.feedback.timestamp = rospy.get_rostime()
			self._as.publish_feedback(self.feedback)

			i += 1
			rospy.sleep(0.7)

		del words[:]
开发者ID:rizasif,项目名称:Robotics_intro,代码行数:58,代码来源:tts_to_soundplay.py

示例9: Robbie_Chat

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class Robbie_Chat():

    def __init__(self):
        rospy.init_node('robbie_chat_node', anonymous=True)
        self.kern = aiml.Kernel()
        self.kern.setBotPredicate("name","robbie")
        self.kern.setBotPredicate("location","Australia")
        self.kern.setBotPredicate("botmaster","Petrus")
        self.kern.setBotPredicate("gender","male")
        self.brainLoaded = False
        self.forceReload = False
        # Set the default TTS voice to use
        self.voice = rospy.get_param("~voice", "voice_don_diphone")
        self.robot = rospy.get_param("~robot", "robbie")
        # Create the sound client object
        self.soundhandle = SoundClient()
        
        # Wait a moment to let the client connect to the
        # sound_play server
        rospy.sleep(1)
        
        # Make sure any lingering sound_play processes are stopped.
        self.soundhandle.stopAll()

        while not self.brainLoaded:
	    if self.forceReload or (len(sys.argv) >= 2 and sys.argv[1] == "reload"):
		    # Use the Kernel's bootstrap() method to initialize the Kernel. The
		    # optional learnFiles argument is a file (or list of files) to load.
		    # The optional commands argument is a command (or list of commands)
		    # to run after the files are loaded.
                    #self.kern.setBotPredicate(name. robbie)
		    self.kern.bootstrap(learnFiles="std-startup.xml", commands="load aiml b")
		    self.brainLoaded = True
		    # Now that we've loaded the brain, save it to speed things up for
		    # next time.
		    self.kern.saveBrain("standard.brn")
	    else:
		    # Attempt to load the brain file.  If it fails, fall back on the Reload
		    # method.
		    try:
			    # The optional branFile argument specifies a brain file to load.
			    self.kern.bootstrap(brainFile = "standard.brn")
			    self.brainLoaded = True
		    except:
			    self.forceReload = True


        
        rospy.Subscriber('/speech_text', String, self.speak_text)



    def speak_text(self, text):
        self.soundhandle.say(self.kern.respond(text.data), self.voice)
开发者ID:JanMichaelQuadrant16,项目名称:robo_hand_01,代码行数:56,代码来源:test2.py

示例10: main

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
def main():
    rospy.init_node('eys_move', anonymous = True)
    soundhandle = SoundClient()
    close_eye_publisher = rospy.Publisher("close_eye", Int32, queue_size=10)
    rospy.sleep(1)
    soundhandle.stopAll()

    close_eye_publisher.publish(Int32(data=2))

    wave_path = os.path.dirname(os.path.abspath(__file__)) + "/../sounds/camera.wav"
    soundhandle.playWave(wave_path)
    sleep(2)
开发者ID:TKatayama,项目名称:eye_see,代码行数:14,代码来源:sample.py

示例11: __init__

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class Speech_Interact:
    def __init__(self):
        rospy.on_shutdown(self.cleanup)

        self.rate = rospy.get_param("~rate", 5)
        r = rospy.Rate(self.rate)
          
        self.voice = rospy.get_param("~voice", "voice_don_diphone")
        self.wavepath = rospy.get_param("~wavepath", "")
        
        # Create the sound client object
        self.soundhandle = SoundClient()
        
        rospy.sleep(1)
        self.soundhandle.stopAll()
        
        # Announce that we are ready for input
        self.soundhandle.playWave(self.wavepath + "/R2D2a.wav")
        rospy.sleep(1)
        self.soundhandle.say("Ready", self.voice)

        # Subscribe to the recognizer output
        rospy.Subscriber('/recognizer/output', String, self.identify)


	while not rospy.is_shutdown():
    		r.sleep()                       



    def identify(self, msg):

    	if msg.data == 'hello':
        	rospy.loginfo(msg.data)
        	self.soundhandle.say("hello", self.voice)
        	rospy.sleep(1)

    	elif msg.data == 'how are you'
        	rospy.loginfo(msg.data)
        	self.soundhandle.say("I am fine", self.voice)
        	rospy.sleep(1)

    	elif msg.data == 'who are you'
        	rospy.loginfo(msg.data)
        	self.soundhandle.say("I am turtle", self.voice)
        	rospy.sleep(1)


    def cleanup(self):
        rospy.loginfo("Shutting down voice interaction...")
        twist = Twist()
        self.cmd_vel_pub.publish(twist)
开发者ID:amuaz2,项目名称:kamerider,代码行数:54,代码来源:speech_interaction.py

示例12: __init__

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class TalkBack:
    def __init__(self, script_path):
        rospy.init_node('talkback')

        rospy.on_shutdown(self.cleanup)
        
        # Set the default TTS voice to use
        self.voice = rospy.get_param("~voice", "voice_don_diphone")
        
        # Set the wave file path if used
        self.wavepath = rospy.get_param("~wavepath", script_path + "/../sounds")
        
        # Create the sound client object
        self.soundhandle = SoundClient()
        
        # Wait a moment to let the client connect to the
        # sound_play server
        rospy.sleep(1)
        
        # Make sure any lingering sound_play processes are stopped.
        self.soundhandle.stopAll()
        
        # Announce that we are ready for input
        self.soundhandle.playWave(self.wavepath + "/R2D2a.wav")
        rospy.sleep(1)
        self.soundhandle.say("Ready", self.voice)
        
        rospy.loginfo("Say one of the navigation commands...")

        # Subscribe to the recognizer output and set the callback function
        rospy.Subscriber('/recognizer/output', String, self.talkback)
        
    def talkback(self, msg):
        # Print the recognized words on the screen
        rospy.loginfo(msg.data)
        
        # Speak the recognized words in the selected voice
        self.soundhandle.say(msg.data, self.voice)
        
        # Uncomment to play one of the built-in sounds
        #rospy.sleep(2)
        #self.soundhandle.play(5)
        
        # Uncomment to play a wave file
        #rospy.sleep(2)
        #self.soundhandle.playWave(self.wavepath + "/R2D2a.wav")

    def cleanup(self):
        self.soundhandle.stopAll()
        rospy.loginfo("Shutting down talkback node...")
开发者ID:Chengxi9,项目名称:rbx1,代码行数:52,代码来源:talkback.py

示例13: BehaviorSwitch

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class BehaviorSwitch(object):
    def __init__(self):
        self.running = True # Will Toggle Auto To False with logic
	self.in_toggle = False
	self.line_follow_toggle = False
	self.line_follow_running = True
    def callback(self, joy_msg):
        if joy_msg.buttons[4] == 1:
	  self.line_follow_toggle = True
	elif joy_msg.buttons[1] == 1:
	  self.in_toggle = True 
	
	if joy_msg.buttons[4] == 0 and self.line_follow_toggle == True:
	  self.line_follow_running = not self.line_follow_running
	  self.line_follow_toggle = False
	  bool_msg = Bool()
	  bool_msg.data = self.line_follow_running;
	  line_follower_enable_pub = rospy.Publisher('line_follower/enable', Bool, queue_size=1)
	  line_follower_enable_pub.publish(bool_msg)
	  self.soundhandle.play(3)
	  rospy.loginfo("Got Toggle Button (Y) %d", self.line_follow_running)
	elif joy_msg.buttons[1] == 0 and self.in_toggle == True:
	  self.running = not self.running
	  self.in_toggle = False
	  rospy.loginfo("Got Toggle Button (B) %d", self.running)
          self.soundhandle.play(1)
        #rospy.loginfo(repr(joy_msg))

    def run(self):
        rospy.init_node('behavior_switch', anonymous=True)
        self.soundhandle = SoundClient()

        rospy.sleep(1)

        self.soundhandle.stopAll()

        pub = rospy.Publisher('cmd_vel_mux/input/switch', Twist, queue_size=10)
        
        
        rospy.Subscriber('joy', Joy, self.callback)
        rate = rospy.Rate(10)
        while not rospy.is_shutdown():
            if self.running:
                empty_msg = Twist()
                pub.publish(empty_msg)
            rate.sleep()
开发者ID:qjones81,项目名称:victor,代码行数:48,代码来源:switch.py

示例14: __init__

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class TalkBack:
    def __init__(self, script_path):
        rospy.init_node('talk_back')
        rospy.on_shutdown(self.cleanup)
        self.voice = rospy.get_param("~voice", "voice_don_diphone")
        self.soundhandle = SoundClient()
        rospy.sleep(1)
        self.soundhandle.stopAll()
        rospy.sleep(1)
        rospy.Subscriber('/follow_me/talk_back', String, self.talk_back)

    def talk_back(self, msg):
        rospy.loginfo(msg.data)

        self.soundhandle.say(msg.data, self.voice)

    def cleanup(self):
        self.soundhandle.stopAll()
        rospy.loginfo("Shutting down talkback node...")
开发者ID:abigcarrot,项目名称:bitathomeSrc,代码行数:21,代码来源:Follow_me_talk_back.py

示例15: __init__

# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import stopAll [as 别名]
class voice_play:
	def __init__(self):
		self.voice = rospy.get_param("~voice", "voice_cmu_us_clb_arctic_clunits")
		self.wavepath = rospy.get_param("~wavepath", "")

		self.sound_handle = SoundClient()

		rospy.sleep(1)
		rospy.loginfo("Say node ready to play...")

		rospy.Subscriber('/speech', String, self.talkback)

	def talkback(self, msg):
		rospy.loginfo(msg.data)
		self.sound_handle.stopAll()
		# rospy.sleep(1)
		# self.sound_handle.playWave(self.wavepath + "R2D2a.wav")
		self.sound_handle.say(msg.data, self.voice)
		rospy.sleep(2)
开发者ID:douglasrizzo,项目名称:rfh_judite,代码行数:21,代码来源:rfh_voice_play.py


注:本文中的sound_play.libsoundplay.SoundClient.stopAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。