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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mic-ts

v0.1.6

Published

A simple stream wrapper for arecord (Linux (including Raspbian)) and sox (Mac/Windows). Returns a Passthrough stream object so that stream control like pause(), resume(), pipe(), etc. are all available.

Readme

mic-ts

Forked from mic with the same interface, a stream simple wrapper of sox.

Installation

This module depends on your machine having an installation of sox for Mac/Win OR arecord for Linux.

npm install mic-ts

Quick Start

import mic from 'mic-ts';

// Create microphone instance
const micInstance = mic({
  rate: '16000',
  channels: '1',
  debug: false,
});

// Get audio stream
const audioStream = micInstance.getAudioStream();

// Listen for audio data
audioStream.on('data', (chunk) => {
  console.log(`Received ${chunk.length} bytes of audio data`);
});

// Start recording
micInstance.start();

// Stop recording after 5 seconds
setTimeout(() => {
  micInstance.stop();
}, 5000);

Events

The audio stream emits several useful events:

audioStream.on('startComplete', () => {
  console.log('Recording started');
});

audioStream.on('stopComplete', () => {
  console.log('Recording stopped');
});

audioStream.on('silence', () => {
  console.log('Silence detected');
});

audioStream.on('sound', () => {
  console.log('Sound detected');
});

audioStream.on('audioProcessExitComplete', () => {
  console.log('Audio process exited');
});

audioStream.on('error', (error) => {
  console.error('Error:', error);
});

Silence Detection

const micInstance = mic({
  exitOnSilence: 5, // Exit after 5 consecutive silent frames
});

const audioStream = micInstance.getAudioStream();

audioStream.on('silence', () => {
  console.log('Silence threshold reached');
  micInstance.stop(); // Auto-stop on silence
});

Advanced Usage

import { writeFileSync } from 'fs';

const micInstance = mic({
  rate: '44100',
  channels: '2',
  bitwidth: '16',
  encoding: 'signed-integer',
  endian: 'little',
  fileType: 'wav',
  debug: true,
});

const audioStream = micInstance.getAudioStream();
const audioChunks = [];

audioStream.on('data', (chunk) => {
  audioChunks.push(chunk);
});

audioStream.on('audioProcessExitComplete', () => {
  // Save recorded audio to file
  const audioData = Buffer.concat(audioChunks);
  writeFileSync('recording.wav', audioData);
  console.log('Audio saved to recording.wav');
});

micInstance.start();

Examples

Check the examples/ directory for complete usage examples:

# Run with tsx (TypeScript execution)
npx tsx examples/simple.ts

# Or run the compiled JavaScript version
node examples/simple.js

System Dependencies

macOS

brew install sox

Linux

sudo apt-get install sox
# or
sudo apt-get install alsa-utils

Windows

choco install sox.portable

API Reference

mic(options)

Creates a new microphone instance.

Options:

  • rate (string): Sample rate (default: '16000')
  • channels (string): Number of channels (default: '1')
  • bitwidth (string): Bit width ('8', '16', or '24') (default: '16')
  • encoding (string): Audio encoding (default: 'signed-integer')
  • endian (string): Byte order ('little' or 'big') (default: 'little')
  • fileType (string): Audio file type (default: 'raw')
  • debug (boolean): Enable debug logging (default: false)
  • exitOnSilence (number): Exit after N silent frames (default: 0)

Methods

  • start(): Start recording audio
  • stop(): Stop recording audio
  • pause(): Pause recording
  • resume(): Resume recording
  • getAudioStream(): Get the audio stream

Acknowledgments

mic was created by Ashish Bajaj [email protected], however missing typing for typescript and the repo is inactive for more then 5 years. This fork aims to preserver the existing interface without breaking changes and migrate the modern JS synctax as well as proper typing.