snowboy package¶
Submodules¶
snowboy.snowboydecoder module¶
-
class
snowboy.snowboydecoder.
ActiveListener
(decoder_model, resource='/Users/panweizhou/Documents/projects/wukong-robot/snowboy/resources/common.res')[源代码]¶ 基类:
object
Active Listening with VAD
-
listen
(interrupt_check=<function ActiveListener.<lambda>>, sleep_time=0.03, silent_count_threshold=15, recording_timeout=100)[源代码]¶ 参数: - interrupt_check – a function that returns True if the main loop needs to stop.
- silent_count_threshold – indicates how long silence must be heard to mark the end of a phrase that is being recorded.
- sleep_time (float) – how much time in second every loop waits.
- recording_timeout – limits the maximum length of a recording.
返回: recorded file path
-
-
class
snowboy.snowboydecoder.
HotwordDetector
(decoder_model, resource='/Users/panweizhou/Documents/projects/wukong-robot/snowboy/resources/common.res', sensitivity=[], audio_gain=1, apply_frontend=False)[源代码]¶ 基类:
object
Snowboy decoder to detect whether a keyword specified by decoder_model exists in a microphone input stream.
参数: - decoder_model – decoder model file path, a string or a list of strings
- resource – resource file path.
- 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.
- audio_gain – multiply input volume by this factor.
- apply_frontend – applies the frontend processing algorithm if True.
-
start
(detected_callback=<function play_audio_file>, interrupt_check=<function HotwordDetector.<lambda>>, sleep_time=0.03, audio_recorder_callback=None, silent_count_threshold=15, recording_timeout=100)[源代码]¶ 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.
参数: - detected_callback – a function or list of functions. The number of items must match the number of models in decoder_model.
- interrupt_check – a function that returns True if the main loop needs to stop.
- sleep_time (float) – how much time in second every loop waits.
- audio_recorder_callback – if specified, this will be called after a keyword has been spoken and after the phrase immediately after the keyword has been recorded. The function will be passed the name of the file where the phrase was recorded.
- silent_count_threshold – indicates how long silence must be heard to mark the end of a phrase that is being recorded.
- recording_timeout – limits the maximum length of a recording.
返回: None
-
class
snowboy.snowboydecoder.
RingBuffer
(size=4096)[源代码]¶ 基类:
object
Ring buffer to hold audio from PortAudio