voicer.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (c) 2018, Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License").
6 # You may not use this file except in compliance with the License.
7 # A copy of the License is located at
8 #
9 # http://aws.amazon.com/apache2.0
10 #
11 # or in the "license" file accompanying this file. This file is distributed
12 # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 # express or implied. See the License for the specific language governing
14 # permissions and limitations under the License.
15 
16 """Usage:
17 
18 (assuming TTS action server has been started via `roslaunch tts tts_polly.launch`)
19 
20 Plain text::
21 
22  $ rosrun tts voicer.py 'Hello World'
23 
24 SSML::
25 
26  $ rosrun tts voicer.py \
27  '<speak>Mary has a <amazon:effect name="whispered">little lamb.</amazon:effect></speak>' \
28  '{"text_type":"ssml"}'
29 """
30 
31 
32 import sys
33 import actionlib
34 import rospy
35 from tts.msg import SpeechAction, SpeechGoal
36 
37 
38 if __name__ == '__main__':
39  rospy.init_node('tts_action_client')
40  client = actionlib.SimpleActionClient('tts', SpeechAction)
41  client.wait_for_server()
42 
43  goal = SpeechGoal()
44 
45  goal.text = sys.argv[1] if len(sys.argv) > 1 else 'I got no idea.'
46  goal.metadata = sys.argv[2] if len(sys.argv) > 2 else ''
47 
48  client.send_goal(goal)
49  client.wait_for_result()
50  print('\n' + client.get_result().response)


tts
Author(s): AWS RoboMaker
autogenerated on Fri Sep 20 2019 03:21:21