-
Notifications
You must be signed in to change notification settings - Fork 1
/
TTS_srv.py
executable file
·58 lines (41 loc) · 1.32 KB
/
TTS_srv.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
50
51
52
53
54
55
56
57
58
#Start ROS2 service client for Soncreo ROS2
from combine import Comb
#g_node = None # global Node
# Channel event callback function
class Soncreo_TTS():
def __init__(self):
# load models
c=Comb()
pass
def talk_callback(request, response):
response.success = True # evtl. return {'success':True} from Cerevoice
g_node.get_logger().info('Incoming Text: %s' % (request.text))
c.inference_audio(request.text)
return response
def main(args=None):
#instance with inference audio function
global g_node
try:
import rclpy
from roboy_cognition_msgs.srv import Talk
except:
print("Roboy_cognition_msgs was not found")
# Init Rclpy
rclpy.init(args=args)
# create node
g_node = rclpy.create_node('minimal_service')
# create service
srv = g_node.create_service(Talk, '/roboy/cognition/speech/synthesis/talk', Soncreo_TTS.talk_callback)
print("Ready to /roboy/cognition/speech/synthesis/talk")
#loading pre trained models
c=Comb()
# Speech Synthesis is ready now.
c.inference_audio("Speech synthesis is ready now")
# loop RCLpy
while rclpy.ok():
rclpy.spin_once(g_node)
# Destroy Service
g_node.destroy_service(srv)
rclpy.shutdown()
if __name__ == '__main__':
main()