Socket
Book a DemoInstallSign in
Socket

rustpotter-worklet

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rustpotter-worklet

An open source wakeword spotter forged in rust

3.0.3
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Rustpotter Worklet

Description

Run Rustpotter (an open source wake word spotter forged in rust) in the browser as an AudioWorkletProcessor.

This package exposed a RustpotterService class that you can use to create and communicate with a worklet that runs rustpotter on its thread.

The RustpotterService should be able to download the code for the worklet and the rustpotter wasm module, by default it assumes the files "/rustpotter-worker.js", "/rustpotter-worklet.js" and "/rustpotter_wasm_bg.wasm" are available for download.

Basic Usage Example

    import { RustpotterService } from "rustpotter-worklet";
    // Urls to the requires sources
    const wasmModuleUrl = new URL('../node_modules/rustpotter-worklet/dist/rustpotter_wasm_bg.wasm', import.meta.url);
    const workletUrl = new URL('../node_modules/rustpotter-worklet/dist/rustpotter-worklet.js', import.meta.url);
    const workerUrl = new URL('../node_modules/rustpotter-worklet/dist/rustpotter-worker.js', import.meta.url);
    // Init audio context
    const audioContext = new AudioContext();
    const rustpotter = await RustpotterService.new({
        workletPath: workletUrl.href,
        workerPath: workerUrl.href,
        wasmPath: wasmModuleUrl.href,
        averagedThreshold: 0.25,
        threshold: 0.5,
        sampleRate: audioContext.sampleRate
    });
    rustpotter.onDetection(d => console.log(d));
    rustpotter.addWakewordByPath("/static/wakeword.rpw");
    let rustpotterWorklet = rustpotter.getNodeProcessor();
    // get media stream source node (requires user interaction event)
    const stream = await navigator.mediaDevices.getUserMedia({
        audio: {
            autoGainControl: true,
            echoCancellation: true,
            noiseSuppression: true,
        },
        video: false,
    });
    const sourceNode = audioContext.createMediaStreamSource(stream);
    // chain rustpotter audio processor
    sourceNode.connect(rustpotterWorklet);
    ...
    // If you need to recreate the worklet because the audio streaming was interrupted
    rustpotter.disposeNodeProcessor();
    rustpotterWorklet = rustpotter.getNodeProcessor();
    ...
    // If you want to dispose rustpotter
    rustpotter.close();



FAQs

Package last updated on 16 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.