Cross-platform, low-latency microphone streaming for Node.js

No ffmpeg. No SoX. No setup. Capture audio from the system microphone and pipe it anywhere: speech engines, WebSockets, or files.

Install with one command:

$ npm install @analyticsinmotion/micstream Copied!

Then start streaming:

JavaScript
const MicStream = require('@analyticsinmotion/micstream');
const mic = new MicStream({ sampleRate: 16000, channels: 1 });

mic.on('data', (chunk) => {
  websocket.send(chunk); // stream audio to your backend
});

Microphone input in Node.js is harder than it should be

Requires external tools like ffmpeg or SoX
Inconsistent across macOS, Windows, and Linux
Subprocess overhead and complex setup
Painful setup for something that should be simple

Designed for real-time systems

A native Node.js addon wrapping PortAudio. Statically linked, zero system dependencies, with pre-built binaries so there's nothing to compile.

Cross-platform

macOS, Windows, and Linux with pre-built binaries. No build tools required on any platform.

Direct capture

100ms audio chunks by default (1600 frames at 16kHz). PortAudio captures directly from the OS audio layer with no subprocess, no shell, and no intermediate encoding.

Stream interface

Standard Node.js Readable stream. Pipe to files, WebSockets, or speech engines directly.

Zero dependencies

No ffmpeg, no SoX, no system audio libraries. PortAudio is compiled and statically linked.

TypeScript ready

Bundled type definitions. Full IntelliSense for options, events, and device enumeration.

Configurable

Sample rate, channels, frames per buffer, device selection by index or name, int16 or float32 output, and optional voice activity detection with speech/silence events.

Built for real-time voice applications

Real-time transcription
Wake word detection
Voice agents & assistants
Streaming audio pipelines
Speech-to-text engines
Audio monitoring

Record audio to disk

Because micstream exposes a standard Node.js Readable stream, you can pipe audio directly to a file. Set the sample rate and channels to match your target format. No encoding step, no intermediate buffers.

Pipe to file
const MicStream = require('@analyticsinmotion/micstream');
const fs = require('fs');

const mic = new MicStream({ sampleRate: 44100, channels: 2 });
mic.pipe(fs.createWriteStream('capture.raw'));

Works with your existing stack

micstream outputs raw 16-bit PCM, the standard format expected by speech and audio processing engines.

whisper.cpp sherpa-onnx Vosk openWakeWord WebSocket servers Custom pipelines

The right tool for the job

Use micstream when you need raw PCM audio from a system microphone inside a Node.js process. For example, feeding audio to a local speech-to-text engine, a wake word detector, or a real-time WebSocket pipeline. If you need browser-based audio capture, use the Web Audio API or microphone-stream instead.

Other approaches

  • mic npm package requires SoX or arecord installed on the system
  • microphone-stream is browser-only and does not work in Node.js
  • Shelling out to ffmpeg adds latency, process management, and a large dependency
  • Most alternatives have no prebuilt binaries and require build tools on every machine

micstream

  • Native PortAudio addon with no system audio tools needed
  • Purpose-built for Node.js server-side and CLI use cases
  • Prebuilt binaries ship in the package with zero post-install setup
  • Standard Readable stream API: pipe, transform, and compose

Pre-built binaries, zero setup

Pre-compiled native binaries ship inside the package. No build tools, no compilation, no post-install downloads.

Windows 11
x64
macOS
arm64 (Apple Silicon)
Linux
x64
Linux
arm64

Common questions

What audio format does micstream output?

16-bit signed integer PCM, little-endian by default. A 32-bit float format is also available. The default is the raw format expected by most speech and wake-word engines including Vosk, sherpa-onnx, and whisper.cpp.

Does micstream require ffmpeg, SoX, or any system audio tools?

No. micstream bundles PortAudio as a statically linked native addon. There are no system dependencies to install.

Do I need build tools to install micstream?

No. Pre-built binaries for Windows x64, macOS arm64, and Linux x64/arm64 ship inside the npm package. If no binary is available for your platform, it falls back to compiling from source.

Does micstream work in the browser?

No. micstream is a native Node.js addon for server-side and CLI use. For browser-based audio capture, use the Web Audio API or the microphone-stream package.

Can I select a specific microphone?

Yes. Use MicStream.devices() to list available input devices, then pass the device index or a name substring to the constructor options.

What Node.js versions are supported?

Node.js 16 and above.

What license is micstream released under?

Apache-2.0.

Start streaming audio in minutes

One install. One import. Real-time microphone audio.

$ npm install @analyticsinmotion/micstream Copied!