コード例 #1
0
ファイル: pal_hci.py プロジェクト: efernandez/pal_python
def tts_speak(text, wait_before_speaking=0):
    """
    Lets the robot say the given text out aloud. This is a blocking call.
    """

    from text_to_speech.msg import SoundAction, SoundGoal

    global __tts_client
    if __tts_client is None:
        __tts_client = actionlib.SimpleActionClient(TTS_ACTION_NAME, SoundAction)
        rospy.logdebug('Waiting for "%s"...' % TTS_ACTION_NAME)
        if not __tts_client.wait_for_server(rospy.Duration(1.0)):
            rospy.logwarn('Couldn\'t connect to "%s" server.' % TTS_ACTION_NAME)
            return False

    tts_goal = SoundGoal()
    tts_goal.wait_before_speaking = rospy.Duration(wait_before_speaking)
    tts_goal.text = text

    rospy.logdebug('Sent speak command with "%s" (wait: %.3f seconds).' % (
        text, wait_before_speaking))
    __tts_client.send_goal(tts_goal)
    __tts_client.wait_for_result()

    result = __tts_client.get_state()
    rospy.logdebug('Result for last speech command: %s' % result)
    return result == GoalStatus.SUCCEEDED
コード例 #2
0
def tts_speak(text, wait_before_speaking=0):
    """
    Lets the robot say the given text out aloud. This is a blocking call.
    """

    from text_to_speech.msg import SoundAction, SoundGoal

    global __tts_client
    if __tts_client is None:
        __tts_client = actionlib.SimpleActionClient(TTS_ACTION_NAME,
                                                    SoundAction)
        rospy.logdebug('Waiting for "%s"...' % TTS_ACTION_NAME)
        if not __tts_client.wait_for_server(rospy.Duration(1.0)):
            rospy.logwarn('Couldn\'t connect to "%s" server.' %
                          TTS_ACTION_NAME)
            return False

    tts_goal = SoundGoal()
    tts_goal.wait_before_speaking = rospy.Duration(wait_before_speaking)
    tts_goal.text = text

    rospy.logdebug('Sent speak command with "%s" (wait: %.3f seconds).' %
                   (text, wait_before_speaking))
    __tts_client.send_goal(tts_goal)
    __tts_client.wait_for_result()

    result = __tts_client.get_state()
    rospy.logdebug('Result for last speech command: %s' % result)
    return result == GoalStatus.SUCCEEDED
コード例 #3
0
ファイル: tts.py プロジェクト: po1/rockin_snippets
def createTTSGoal(text, lang_id='', wait_before_speaking=rospy.Duration(0.0)):
    """Creates a 
    @arg j1 float value for head_1_joint
    @returns FollowJointTrajectoryGoal with the specified goal"""
    sound_goal = SoundGoal()
    sound_goal.text=text
    sound_goal.lang_id=lang_id
    sound_goal.wait_before_speaking=wait_before_speaking
    return sound_goal
コード例 #4
0
ファイル: sound_action.py プロジェクト: jypuigbo/robocup-code
 def generic_goal_cb(userdata, old_goal):
     tts_goal = SoundGoal()
     tts_goal.wait_before_speaking = wait_before_speaking
     tts_goal.text = text if text else text_cb(userdata)
     print "Speaking:", tts_goal.text
     return tts_goal