npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ozymandiasthegreat/wakeword-zero

v2.0.5

Published

Personal wake word detector ported to TypeScript/WASM, running in browsers, Node, and NativeScript

Downloads

38

Readme

wakeword-zero

Based on Machine Learning on Voice: a gentle introduction with Snips Personal Wake Word Detector

Ported from node-personal-wakeword by Mathieu Quisefit

Installation

npm install @ozymandiasthegreat/wakeword-zero

Usage

import { DetectorBuilder } from "@ozymandiasthegreat/wakeword-zero";

const Detector = await DetectorBuilder();
const detector = new Detector({
  /*
  sampleRate: 16000,
  bitLength: 16,
  frameShiftMS: 10.0,
  frameLengthMS: 30.0, // Must be a multiple of frameShiftMS
  vad: true, // Use VAD detection
  vadMode: WakewordDetector.VadMode.AGGRESSIVE, // See node-vad modes
  vadDebounceTime: 500,
  band: 5, // DTW window width
  ref: 0.22, // See Snips paper for explanation about this parameter
  preEmphasisCoefficient: 0.97, // Pre-emphasis ratio
  */
  threshold: 0.5 // Default value
})

// *****

// KEYWORD MANAGEMENT

// Add a new keyword using multiple "templates"
await detector.addKeyword('alexa', [
  // WAV templates (trimmed with no noise!)
  './keywords/alexa1.wav',
  './keywords/alexa2.wav',
  './keywords/alexa3.wav'
], {
  // Options
  disableAveraging: true, // Disabled by default, disable templates averaging (note that resources consumption will increase)
  threshold: 0.52 // Per keyword threshold
})

// Keywords can be enabled/disabled at runtime
detector.disableKeyword('alexa')
detector.enableKeyword('alexa')

// *****

// EVENTS

// The detector will emit a "ready" event when its internal audio frame buffer is filled
detector.on('ready', () => {
  console.log('listening...')
})

// The detector will emit an "error" event when it encounters an error (VAD, feature extraction, etc.)
detector.on('error', err => {
  console.error(err.stack)
})

// The detector will emit a "data" event when it has detected a keyword in the audio stream
/* The event payload is:
  {
    "keyword"     : "alexa", // The detected keyword
    "score"       : 0.56878768987, // The detection score
    "threshold"   : 0.5, // The detection threshold used (global or keyword)
    "frames"      : 89, // The number of audio frames used in the detection
    "timestamp"   : 1592574404789, // The detection timestamp (ms)
    "audioData"   : <Buffer> // The utterance audio data (can be written to a file for debugging)
  }
*/
detector.on('data', ({keyword, score, threshold, timestamp}) => {
  console.log(`Detected "${keyword}" with score ${score} / ${threshold}`)
})

// *****

// Create readable stream and
// Pipe to wakeword detector
stream.pipe(detector)

// Or push audio data in chunks
detector.write(chunk)

For a complete example check out the docs folder.