Skip to content

Commit

Permalink
Add STT service
Browse files Browse the repository at this point in the history
  • Loading branch information
Waguramu authored May 15, 2019
1 parent cc14c44 commit 36b71c3
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions STT_srv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os

from roboy_cognition_msgs.msg import RecognizedSpeech
from roboy_cognition_msgs.srv import RecognizeSpeech

from asr_interface import IAsr
import rclpy
from rclpy.node import Node


class SonoscoROS2(Node):
def __init__(self):
super().__init__('stt')
self.publisher = self.create_publisher(RecognizedSpeech, '/roboy/cognition/speech/recognition')
self.srv = self.create_service(RecognizeSpeech, '/roboy/cognition/speech/recognition/recognize', self.asr_callback)
print("Ready to /roboy/cognition/speech/recognition/recognize")
print(f"Roboy Sonosco running with PID: {os.getpid()}")
self.i=IAsr()
print(f"Status: Speech recognition is ready now!")
print("Roboy Sonosco is ready!")

def asr_callback(self, request, response):
response.success = True
self.get_logger().info('Incoming Audio')
msg = RecognizedSpeech()
self.i.inference_audio(request)
self.publisher.publish(msg)
return response


def main(args=None):
rclpy.init(args=args)

stt = SonoscoROS2()

while rclpy.ok():
rclpy.spin_once(stt)

rclpy.shutdown()


if __name__ == '__main__':
main()

0 comments on commit 36b71c3

Please sign in to comment.