-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTTS_srv_new.py
executable file
·49 lines (37 loc) · 1.34 KB
/
TTS_srv_new.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from roboy_cognition_msgs.srv import Talk
from roboy_cognition_msgs.msg import SpeechSynthesis
from combine import Comb
import rclpy
from rclpy.node import Node
class Soncreo_TTS(Node):
def __init__(self):
super().__init__('soncreo_tts')
self.publisher = self.create_publisher(SpeechSynthesis, '/roboy/cognition/speech/synthesis')
self.srv = self.create_service(Talk, '/roboy/cognition/speech/synthesis/talk', self.talk_callback)
print("Ready to /roboy/cognition/speech/synthesis/talk")
self.c=Comb()
print("speech synthesis is ready now")
self.c.inference_audio("Speech synthesis is ready now")
def talk_callback(self, request, response):
response.success = True # evtl. return {'success':True}
self.get_logger().info('Incoming Text: %s' % (request.text))
msg = SpeechSynthesis()
msg.duration = 5
msg.phoneme = 'o'
self.publisher.publish(msg)
try:
self.c.inference_audio(request.text)
except:
pass
msg.phoneme = 'sil'
msg.duration = 0
self.publisher.publish(msg)
return response
def main(args=None):
rclpy.init(args=args)
soncreo_tts = Soncreo_TTS()
while rclpy.ok():
rclpy.spin_once(soncreo_tts)
rclpy.shutdown()
if __name__ == '__main__':
main()