From c1caa182be1e7ede1e48c1e18fc8f065737e234e Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 25 May 2018 18:26:02 +0200 Subject: [PATCH] Handling assistant no_response events --- platypush/backend/assistant/google/__init__.py | 5 ++++- platypush/message/event/assistant/__init__.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/platypush/backend/assistant/google/__init__.py b/platypush/backend/assistant/google/__init__.py index 0ffc152f4..ce0dcbc99 100644 --- a/platypush/backend/assistant/google/__init__.py +++ b/platypush/backend/assistant/google/__init__.py @@ -12,7 +12,8 @@ from google.assistant.library.file_helpers import existing_file from platypush.backend import Backend from platypush.message.event.assistant import \ - ConversationStartEvent, ConversationEndEvent, ConversationTimeoutEvent, SpeechRecognizedEvent + ConversationStartEvent, ConversationEndEvent, ConversationTimeoutEvent, \ + NoResponseEvent, SpeechRecognizedEvent class AssistantGoogleBackend(Backend): """ Class for the Google Assistant backend. It creates and event source @@ -48,6 +49,8 @@ class AssistantGoogleBackend(Backend): self.bus.post(ConversationEndEvent()) elif event.type == EventType.ON_CONVERSATION_TURN_TIMEOUT: self.bus.post(ConversationTimeoutEvent()) + elif event.type == EventType.ON_NO_RESPONSE: + self.bus.post(NoResponseEvent()) elif event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED: phrase = event.args['text'].lower().strip() logging.info('Speech recognized: {}'.format(phrase)) diff --git a/platypush/message/event/assistant/__init__.py b/platypush/message/event/assistant/__init__.py index fc6febcc3..0cc8d0d6c 100644 --- a/platypush/message/event/assistant/__init__.py +++ b/platypush/message/event/assistant/__init__.py @@ -34,6 +34,11 @@ class ConversationTimeoutEvent(ConversationEndEvent): super().__init__(*args, **kwargs) +class NoResponseEvent(ConversationEndEvent): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + class SpeechRecognizedEvent(AssistantEvent): def __init__(self, phrase, *args, **kwargs): super().__init__(phrase=phrase, *args, **kwargs)