From 4f75b765b1b8c18e89539f42a69fe050f50a6d2b Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 25 May 2018 18:18:16 +0200 Subject: [PATCH] Added assistant conversation timeout event --- platypush/backend/assistant/google/__init__.py | 4 +++- platypush/message/event/assistant/__init__.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/platypush/backend/assistant/google/__init__.py b/platypush/backend/assistant/google/__init__.py index 9edf41d8f..0ffc152f4 100644 --- a/platypush/backend/assistant/google/__init__.py +++ b/platypush/backend/assistant/google/__init__.py @@ -12,7 +12,7 @@ from google.assistant.library.file_helpers import existing_file from platypush.backend import Backend from platypush.message.event.assistant import \ - ConversationStartEvent, ConversationEndEvent, SpeechRecognizedEvent + ConversationStartEvent, ConversationEndEvent, ConversationTimeoutEvent, SpeechRecognizedEvent class AssistantGoogleBackend(Backend): """ Class for the Google Assistant backend. It creates and event source @@ -46,6 +46,8 @@ class AssistantGoogleBackend(Backend): self.bus.post(ConversationStartEvent()) elif event.type == EventType.ON_CONVERSATION_TURN_FINISHED: self.bus.post(ConversationEndEvent()) + elif event.type == EventType.ON_CONVERSATION_TURN_TIMEOUT: + self.bus.post(ConversationTimeoutEvent()) 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 483270c75..fc6febcc3 100644 --- a/platypush/message/event/assistant/__init__.py +++ b/platypush/message/event/assistant/__init__.py @@ -29,6 +29,11 @@ class ConversationEndEvent(AssistantEvent): super().__init__(*args, **kwargs) +class ConversationTimeoutEvent(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)