Skip to content

Commit

Permalink
feat: ListenFor skill.
Browse files Browse the repository at this point in the history
  • Loading branch information
jws-1 committed Mar 11, 2024
1 parent 14f0e6c commit ae05ba9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions skills/src/lasr_skills/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
from .go_to_location import GoToLocation
from .go_to_semantic_location import GoToSemanticLocation
from .say import Say
from .listen_for import ListenFor
25 changes: 25 additions & 0 deletions skills/src/lasr_skills/listen_for.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import smach_ros
from lasr_speech_recognition_msgs.msg import (
TranscribeSpeechAction,
TranscribeSpeechGoal,
)

from actionlib_msgs.msg import GoalStatus


class ListenFor(smach_ros.SimpleActionState):
def __init__(self, wake_word: str):

def speech_result_cb(userdata, status, result):
if status == GoalStatus.SUCCEEDED:
if wake_word in result.transcription.lower().split():
return "succeeded"
return "not_done"
return "failed"

smach_ros.SimpleActionState.__init__(
self,
"transcribe_speech",
TranscribeSpeechAction,
result_cb=speech_result_cb,
)

0 comments on commit ae05ba9

Please sign in to comment.