Public Member Functions | |
def | __init__ (self, decoder_model, resource=RESOURCE_FILE, sensitivity=[], audio_gain=1) |
def | start (self, detected_callback=play_audio_file, interrupt_check=lambda:False, sleep_time=0.03) |
def | terminate (self) |
Public Attributes | |
audio | |
detector | |
num_hotwords | |
ring_buffer | |
stream_in | |
Snowboy decoder to detect whether a keyword specified by `decoder_model` exists in a microphone input stream. :param decoder_model: decoder model file path, a string or a list of strings :param resource: resource file path. :param sensitivity: decoder sensitivity, a float of a list of floats. The bigger the value, the more senstive the decoder. If an empty list is provided, then the default sensitivity in the model will be used. :param audio_gain: multiply input volume by this factor.
Definition at line 59 of file snowboydecoder.py.
def snowboy.snowboydecoder.HotwordDetector.__init__ | ( | self, | |
decoder_model, | |||
resource = RESOURCE_FILE , |
|||
sensitivity = [] , |
|||
audio_gain = 1 |
|||
) |
Definition at line 75 of file snowboydecoder.py.
def snowboy.snowboydecoder.HotwordDetector.start | ( | self, | |
detected_callback = play_audio_file , |
|||
interrupt_check = lambda: False , |
|||
sleep_time = 0.03 |
|||
) |
Start the voice detector. For every `sleep_time` second it checks the audio buffer for triggering keywords. If detected, then call corresponding function in `detected_callback`, which can be a single function (single model) or a list of callback functions (multiple models). Every loop it also calls `interrupt_check` -- if it returns True, then breaks from the loop and return. :param detected_callback: a function or list of functions. The number of items must match the number of models in `decoder_model`. :param interrupt_check: a function that returns True if the main loop needs to stop. :param float sleep_time: how much time in second every loop waits. :return: None
Definition at line 120 of file snowboydecoder.py.
def snowboy.snowboydecoder.HotwordDetector.terminate | ( | self | ) |
Terminate audio stream. Users cannot call start() again to detect. :return: None
Definition at line 176 of file snowboydecoder.py.
snowboy.snowboydecoder.HotwordDetector.audio |
Definition at line 107 of file snowboydecoder.py.
snowboy.snowboydecoder.HotwordDetector.detector |
Definition at line 90 of file snowboydecoder.py.
snowboy.snowboydecoder.HotwordDetector.num_hotwords |
Definition at line 93 of file snowboydecoder.py.
snowboy.snowboydecoder.HotwordDetector.ring_buffer |
Definition at line 105 of file snowboydecoder.py.
snowboy.snowboydecoder.HotwordDetector.stream_in |
Definition at line 108 of file snowboydecoder.py.