本文整理汇总了Python中sound_play.libsoundplay.SoundClient.say方法的典型用法代码示例。如果您正苦于以下问题:Python SoundClient.say方法的具体用法?Python SoundClient.say怎么用?Python SoundClient.say使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sound_play.libsoundplay.SoundClient
的用法示例。
在下文中一共展示了SoundClient.say方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [as 别名]
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()
示例2: __init__
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [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...")
示例3: __init__
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [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
示例4: play_nonblocking
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [as 别名]
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.')
示例5: __init__
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [as 别名]
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: __init__
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [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)
示例7: __init__
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [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)
示例8: __init__
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [as 别名]
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')
示例9: SoundIntermediary
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [as 别名]
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)
示例10: __init__
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [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
示例11: TtsServer
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [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[:]
示例12: __init__
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [as 别名]
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)
示例13: Robbie_Chat
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [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)
示例14: wel
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [as 别名]
def wel(filename):
#absolute path for this
print filename
fileloc = str( str(os.path.dirname(__file__)) +'/'+ filename)
f = open(fileloc, 'r')
#rospy.init_node('say', anonymous = True)
soundhandle = SoundClient()
rospy.sleep(1)
s = f.read()
print s
soundhandle.say(s,'voice_kal_diphone')
#may be loop with readline so there is a pause at every line.
rospy.sleep(1)
示例15: SaySomething
# 需要导入模块: from sound_play.libsoundplay import SoundClient [as 别名]
# 或者: from sound_play.libsoundplay.SoundClient import say [as 别名]
class SaySomething(object):
def __init__(self, speech):
self._speech = speech
self._client = SoundClient()
def start_goal(self):
self._client.say(self._speech, 'voice_us1_mbrola')
def start(self):
pass
def stop(self):
pass