Socket
Book a DemoInstallSign in
Socket

@usefulsensors/moonshine-js

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@usefulsensors/moonshine-js

On-device speech-to-text and voice control for web applications with Moonshine.

0.1.21
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

MoonshineJS

MoonshineJS makes it easy for web developers to build modern, speech-driven web experiences without sacrificing user privacy. We build on three key principles:

  • Fast Transcription: simply connect a WebAudio-compliant media stream from any browser audio source and generate rapid transcriptions of speech.
  • Easy Voice Control: build feature-rich voice-controlled web apps in < 10 lines of code.
  • Local Processing: all audio processing happens locally in the user's web browser---no cloud services or privacy violations required.

Note: This package is currently in beta, and breaking changes may occur between versions. User feedback and developer contributions are welcome.

Installation

You can use MoonshineJS via CDN, or you can install it with npm. Simply import the package depending on your preferred method.

Via CDN

import * as Moonshine from "https://cdn.jsdelivr.net/npm/@usefulsensors/moonshine-js@latest/dist/moonshine.min.js";

Via npm

Install the package first:

npm install @usefulsensors/moonshine-js

Then import:

import * as Moonshine from "@usefulsensors/moonshine-js";

Quickstart

Let's get started with a simple example. We'll create a transcriber to print speech from the microphone to the console. We can use the MicrophoneTranscriber for that. You can control the behavior of the transcriber by passing it a set of callbacks when you create it:

import * as Moonshine from "https://cdn.jsdelivr.net/npm/@usefulsensors/moonshine-js@latest/dist/moonshine.min.js";

var transcriber = new Moonshine.MicrophoneTranscriber(
    "model/tiny", // the fastest and smallest Moonshine model
    {
        onTranscriptionUpdated(text) {
            console.log(text);
        },
    }
);

transcriber.start();

When we start the transcriber, the browser will request mic permissions and begin printing everything the user says to the console. It is useful in some cases to wait until the user has stopped speaking to transcribe their words. In this case, we'll enable voice activity detection (VAD) when we create the transcriber:

var transcriber = new Moonshine.MicrophoneTranscriber(
    "model/tiny",
    {
        onTranscriptionUpdated(text) {
            console.log(text);
        },
    },
    true // enable voice activity detection
);

transcriber.start();

Now the transcription will only update between pauses in speech.

That's all it takes to get started! Read the guides to learn how to transcribe audio from other sources, or to build voice-controlled applications.

Web Speech Polyfill

MoonshineJS also provides a polyfill for the Web Speech API. Usage is as follows:

import * as Moonshine from "https://cdn.jsdelivr.net/npm/@usefulsensors/moonshine-js@latest/dist/moonshine.min.js";

var transcriber = new Moonshine.MoonshineSpeechRecognition();

transcriber.addEventListener("result", (e) => {
    console.log("result:", e.results[0][0].transcript);
});

Credit

MoonshineJS is developed and maintained by Useful Sensors.

License

The code in this repo and the English-language Moonshine speech to text model it uses are released under the MIT license. The Spanish-language speech to text model is released under the Moonshine AI Community License for researchers, developers, small businesses, and creators with less than $1M in annual revenue.

Keywords

asr

FAQs

Package last updated on 16 Jun 2025

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.