Skip to content

Commit

Permalink
feat: working launch file and quesiton answering with TTS
Browse files Browse the repository at this point in the history
  • Loading branch information
m-barker committed Mar 6, 2024
1 parent 014c6e9 commit e234f9d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
8 changes: 8 additions & 0 deletions tasks/gpsr/launch/question_answer.launch
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@
args="--k $(arg k) --index_path $(arg index_path) --txt_path $(arg text_path) --xml_path $(arg xml_path)"
/>

<node
pkg="lasr_speech_recognition_whisper"
type="transcribe_microphone_server"
name="transcribe_speech"
output="screen"
args="--mic_device 5"
/>

</launch>
25 changes: 12 additions & 13 deletions tasks/gpsr/nodes/question_answer
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 1 addition & 0 deletions tasks/gpsr/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<buildtool_depend>catkin</buildtool_depend>
<depend>lasr_vector_databases_faiss</depend>
<depend>lasr_vector_databases_msgs</depend>
<depend>lasr_speech_recognition_whisper</depend>
<!-- <build_depend>catkin_virtualenv</build_depend> -->
<!-- The export tag contains other, unspecified, tags -->
<export>
Expand Down

0 comments on commit e234f9d

Please sign in to comment.