From e234f9dd62c61e69befa33d349f6edce2d15cb22 Mon Sep 17 00:00:00 2001 From: m-barker Date: Wed, 6 Mar 2024 15:57:43 +0000 Subject: [PATCH] feat: working launch file and quesiton answering with TTS --- tasks/gpsr/launch/question_answer.launch | 8 ++++++++ tasks/gpsr/nodes/question_answer | 25 ++++++++++++------------ tasks/gpsr/package.xml | 1 + 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tasks/gpsr/launch/question_answer.launch b/tasks/gpsr/launch/question_answer.launch index 87de56930..79c3a6fb2 100644 --- a/tasks/gpsr/launch/question_answer.launch +++ b/tasks/gpsr/launch/question_answer.launch @@ -19,4 +19,12 @@ args="--k $(arg k) --index_path $(arg index_path) --txt_path $(arg text_path) --xml_path $(arg xml_path)" /> + + \ No newline at end of file diff --git a/tasks/gpsr/nodes/question_answer b/tasks/gpsr/nodes/question_answer index fe00ce725..e7541a5b0 100644 --- a/tasks/gpsr/nodes/question_answer +++ b/tasks/gpsr/nodes/question_answer @@ -76,18 +76,17 @@ def parse_args() -> dict: if __name__ == "__main__": rospy.init_node("gpsr_question_answer") args: dict = parse_args() - print(args) - q_a_sm = QuestionAnswerStateMachine(args) - outcome = q_a_sm.execute() - voice = Voice() - if outcome == "succeeded": - rospy.loginfo(f"Question: {args['question']}") - rospy.loginfo(f"Closest Answers: {q_a_sm.userdata.closest_answers}") - voice.sync_tts( - f"The answer to your question is: {q_a_sm.userdata.closest_answers[0]}" - ) - else: - rospy.logerr("Question Answer State Machine failed") - voice.sync_tts(f"Sorry, I wasn't able to find an answer to your question") + while not rospy.is_shutdown(): + q_a_sm = QuestionAnswerStateMachine(args) + outcome = q_a_sm.execute() + voice = Voice() + if outcome == "succeeded": + rospy.loginfo(f"Closest Answers: {q_a_sm.userdata.closest_answers}") + voice.sync_tts( + f"The answer to your question is: {q_a_sm.userdata.closest_answers[0]}" + ) + else: + rospy.logerr("Question Answer State Machine failed") + voice.sync_tts(f"Sorry, I wasn't able to find an answer to your question") rospy.spin() diff --git a/tasks/gpsr/package.xml b/tasks/gpsr/package.xml index d9d8689e5..cf974db17 100644 --- a/tasks/gpsr/package.xml +++ b/tasks/gpsr/package.xml @@ -51,6 +51,7 @@ catkin lasr_vector_databases_faiss lasr_vector_databases_msgs + lasr_speech_recognition_whisper