# 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

  `saveMessage`()

    Save the message stored in self.recordedData to a timestamped file.

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.

  `saveMessage`()

    Save the message stored in self.recordedData to a timestamped file.

  `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

  `terminate`()

    Terminate audio stream. Users can call start() again to detect. :return: None

class `snowboy.snowboydecoder.``RingBuffer`(size=4096)

  基类：`object`

  Ring buffer to hold audio from PortAudio

  `extend`(data)

    Adds data to the end of buffer

  `get`()

    Retrieves data from the beginning of buffer and clears it

`snowboy.snowboydecoder.``no_alsa_error`()

`snowboy.snowboydecoder.``play_audio_file`(fname='/Users/panweizhou/Documents/projects/wukong-robot/snowboy/resources/ding.wav')

  Simple callback function to play a wave file. By default it plays a Ding sound.

  参数: | fname (str) – wave file name
  返回: | None

`snowboy.snowboydecoder.``py_error_handler`(filename, line, function, err, fmt)

## snowboy.snowboydetect module

class `snowboy.snowboydetect.``SnowboyDetect`(resource_filename, model_str)

  基类：`object`

  `ApplyFrontend`(apply_frontend)
  `BitsPerSample`()
  `GetSensitivity`()
  `NumChannels`()
  `NumHotwords`()
  `Reset`()
  `RunDetection`(*args)
  `SampleRate`()
  `SetAudioGain`(audio_gain)
  `SetHighSensitivity`(high_sensitivity_str)
  `SetSensitivity`(sensitivity_str)
  `UpdateModel`()

class `snowboy.snowboydetect.``SnowboyVad`(resource_filename)

  基类：`object`

  `ApplyFrontend`(apply_frontend)
  `BitsPerSample`()
  `NumChannels`()
  `Reset`()
  `RunVad`(*args)
  `SampleRate`()
  `SetAudioGain`(audio_gain)

## Module contents