Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/utterance_cancel #217

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1878,9 +1878,19 @@ def on_extension(msg):
LOG.debug(f"Extending get_response wait time: {msg.msg_type}")
start = time.time() # reset timer

def on_abort(msg):
nonlocal start
s = SessionManager.get(msg)
if s.session_id == session.session_id:
# ovos-utterance-cancel-plugin usually
LOG.debug("Aborting get_response")
self.__responses[session.session_id] = None
start = time.time() + timeout + 1

# if we have indications listener is busy, we allow extra time
self.bus.on("recognizer_loop:record_begin", on_extension)
self.bus.on("recognizer_loop:record_end", on_extension)
self.bus.on("ovos.utterance.cancelled", on_abort)

while time.time() - start <= timeout and not ans:
ans = self.__responses[session.session_id]
Expand All @@ -1896,6 +1906,7 @@ def on_extension(msg):

self.bus.remove("recognizer_loop:record_begin", on_extension)
self.bus.remove("recognizer_loop:record_end", on_extension)
self.bus.remove("ovos.utterance.cancelled", on_abort)
return ans

def get_response(self, dialog: str = '', data: Optional[dict] = None,
Expand Down
Loading