-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |