MagicMirror² v2.12.0 is available! For more information about this release, check out this topic.

[npm library] @bugsounet/snowboy


  • Module Developer

    @bugsounet/snowboy

    I created this library if you want use snowboy in your module.
    This library is very simplified and ready for use in your node_helper.js

    This library is used in MMM-GoogleAssistant, MMM-Snowboy, MMM-AssistantMk2

    Dependencies

    For listening keyword, you have to use a mic, so snowboy need some dependencies to use it

    sudo apt install libmagic-dev libatlas-base-dev sox libsox-fmt-all build-essential
    

    Installation

    npm install @bugsounet/snowboy
    

    In the ending of installation, if you use electron you can do electron rebuild step.

    Do you want to execute electron rebuild ? [Y/n]
    Your choice:
    

    Sample with new Snowboy contructor

    /** sample code for using snowboy library **/
    /** @bugsounet **/
    
    const Snowboy = require("@bugsounet/snowboy").Snowboy
    
    var config = {
      debug: true,
      snowboy: {
        audioGain: 2.0,
        Frontend: true,
        Model: "jarvis",
        Sensitivity: null
      },
      micConfig: {
        recorder: "arecord",
        device: "plughw:1",
      },
    }
    
    this.snowboy = new Snowboy(config.snowboy, config.micConfig, (detected) => { detect(detected) }, config.debug )
    this.snowboy.init()
    this.snowboy.start()
    
    function detect(detected) {
      console.log("Make your script if " + detected + " is detected")
    }
    

    constructor of Snowboy

    Snowboy(snowboyConfig, micConfig, callback, debug)

    SnowboyConfig
    • AudioGain - set the gain of mic. Usually you don’t need to set or adjust this value.

    • Frontend - set pre-processing of hotword detection. When you use only snowboy and smart_mirror, false is better. But with other models, true is better to recognize.

    • Model - set the name of your detector. Available: “smart_mirror”, “jarvis”, “computer”, “snowboy”, “subex”, “neo_ya”, “hey_extreme”, “view_glass”

    • Sensitivity - Override default sensitivity value for applied model defined in Model.

      • Value could be within a range from 0.0 to 1.0.

      • Default sensitivity values for preconfigured models are:

        • smart_mirror: 0.5
        • jarvis: 0.7
        • computer: 0.6
        • snowboy: 0.5
        • subex: 0.6
        • neo_ya: 0.7
        • hey_extreme: 0.6
        • view_glass: 0.7
        • alexa: 0.6
      • null will set default sensitivity.

    micConfig
    • recorder - record program, rec, arecord, sox, parec is available.

      • On RaspberryPi or some linux machines, arecord is better.
      • On OSX, rec is better.
      • If you prefer to use pulse audio, parec would be available also.
    • device - recording device (microphone) name of your environment. (e.g. “plughw:1”)

      • Find proper device name by yourself. (arecord -l will be help on Raspberry Pi or linux platform)
    callback

    if snowboy detect a keyword, it return it with his name

    debug

    if you want debuging information, just set to true

    Functions

    • init() : initialize the constructor
    • start() : start listening and waiting for your keyword
    • stop() : force stop listening

Log in to reply