Source code for platypush.message.event.stt
from platypush.message.event import Event
[docs]
class SttEvent(Event):
""" Base class for speech-to-text events """
[docs]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
[docs]
class SpeechStartedEvent(SttEvent):
"""
Event triggered when speech starts being detected.
"""
pass
[docs]
class SpeechDetectedEvent(SttEvent):
"""
Event triggered when speech is detected.
"""
[docs]
def __init__(self, speech: str, *args, **kwargs):
"""
:param speech: Speech detected, as a string
"""
super().__init__(*args, speech=speech.strip(), **kwargs)
[docs]
class ConversationDetectedEvent(SpeechDetectedEvent):
"""
Event triggered when speech is detected after a hotword.
"""
pass
[docs]
class HotwordDetectedEvent(SttEvent):
"""
Event triggered when a custom hotword is detected.
"""
[docs]
def __init__(self, hotword: str = '', *args, **kwargs):
"""
:param hotword: The detected user hotword.
"""
super().__init__(*args, hotword=hotword, **kwargs)
[docs]
class SpeechDetectionStartedEvent(SttEvent):
"""
Event triggered when the speech detection engine starts.
"""
pass
[docs]
class SpeechDetectionStoppedEvent(SttEvent):
"""
Event triggered when the speech detection engine stops.
"""
pass
# vim:sw=4:ts=4:et: