本文整理汇总了Python中sound_play.libsoundplay.SoundClient类的典型用法代码示例。如果您正苦于以下问题:Python SoundClient类的具体用法?Python SoundClient怎么用?Python SoundClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SoundClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: callback
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()
示例2: main
def main():
rospy.init_node(NAME)
# Init Globals with their type
global status_list
status_list = []
global cant_reach_list
cant_reach_list = []
global actionGoalPublisher
# Speech stuff
global soundClient
soundClient = SoundClient()
init_point2pont()
actionStatus = rospy.Subscriber('move_base/status', GoalStatusArray, status_callback)
actionGoalPublisher = rospy.Publisher('move_base/goal', MoveBaseActionGoal, queue_size=10)
frontierSub = rospy.Subscriber('grid_frontier', GridCells, frontier_callback)
rospy.wait_for_message('grid_frontier', GridCells)
rospy.sleep(1)
driveTo.goalID = getHighestStatus()
soundClient.say("Starting Driving")
global closestGoal
while not rospy.is_shutdown():
rospy.loginfo("Waiting for a little while")
rospy.sleep(2) #Allow the goal to be calculated
rospy.loginfo("Getting the closest goal")
closesGoalCopy = getClosestGoal(2)
rospy.loginfo("Getting the current location")
driveTo(closesGoalCopy[0], closesGoalCopy[1], closesGoalCopy[2])
rospy.spin()
示例3: __init__
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...")
示例4: __init__
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
示例5: __init__
class Voice:
def __init__(self, sound_db):
self._sound_client = SoundClient()
rospy.loginfo('Will wait for a second for sound_pay node.')
rospy.sleep(1)
self._sound_db = sound_db
self.play_sound('sound10')
def play_sound(self, sound_name):
'''Plays the requested sound.
Args:
requested_sound (str): Unique name of the sound in the sound database.
'''
sound_filename = self._sound_db.get(sound_name)
self._sound_client.playWave(sound_filename)
# TODO: Make sure this returns when it is done playing the sound.
def say(self, text):
'''Send a TTS (text to speech) command.
Args:
text (str): The speech to say.
'''
self._sound_client.say(text)
示例6: callback
def callback(data):
if str(data) == "data: Bark":
soundhandle = SoundClient()
rospy.sleep(1)
soundhandle.play(1)
pubshoot = rospy.Publisher('bark', String)
pubshoot.publish(String("Fire"))
示例7: __init__
class Talker:
def __init__(self):
#self.talkPublisher = rospy.Publisher("/robotsound", SoundRequest, queue_size=1)
self.soundClient = SoundClient()
rospy.sleep(1)
def say(self, text):
self.soundClient.say(text, 'voice_kal_diphone')
示例8: SoundIntermediary
class SoundIntermediary():
def __init__(self):
self.sound_client = SoundClient()
self.voice = rospy.get_param("~voice", "kal_diphone")
rospy.Subscriber("wt_speech", String, self.speak)
def speak(self, msg):
self.sound_client.say(msg.data, self.voice)
示例9: execute
def execute(self, userdata):
soundhandle = SoundClient()
#let ROS get started...
rospy.sleep(0.5)
soundhandle.stopAll()
return succeeded
示例10: TtsServer
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[:]
示例11: __init__
class FestivalTTS:
def __init__(self):
rospy.init_node('festival_tts')
self._client = SoundClient()
self.voice = 'voice_cmu_us_slt_arctic_hts'
rospy.Subscriber('festival_tts', String, self._response_callback)
rospy.spin()
def _response_callback(self, data):
self._client.say(data.data, self.voice)
示例12: play_nonblocking
def play_nonblocking():
"""
Play the same sounds with manual pauses between them.
"""
rospy.loginfo('Example: Playing sounds in *non-blocking* mode.')
# NOTE: you must sleep at the beginning to let the SoundClient publisher
# establish a connection to the soundplay_node.
soundhandle = SoundClient(blocking=False)
rospy.sleep(1)
# In the non-blocking version you need to sleep between calls.
rospy.loginfo('Playing say-beep at full volume.')
soundhandle.playWave('say-beep.wav')
rospy.sleep(1)
rospy.loginfo('Playing say-beep at volume 0.3.')
soundhandle.playWave('say-beep.wav', volume=0.3)
rospy.sleep(1)
rospy.loginfo('Playing sound for NEEDS_PLUGGING.')
soundhandle.play(SoundRequest.NEEDS_PLUGGING)
rospy.sleep(1)
rospy.loginfo('Speaking some long string.')
soundhandle.say('It was the best of times, it was the worst of times.')
示例13: Robbie_Chat
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)
示例14: __init__
def __init__(self):
if debug:
print "Initializing Sound Client"
SoundClient.__init__(self)
# wait for subscribers
timeout = 10
while timeout > 0:
if self.pub.get_num_connections() > 0:
timeout = 0
else:
rospy.sleep(1)
示例15: main
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)