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

node-audiorecorder

v3.0.0

Published

Record audio via node using SoX or Arecord.

Downloads

2,645

Readme

npm package @latest License agreement Open issues on GitHub

Audio recorder

Audio recorder for Node.js, delivers a 16-bit signed-integer linear pulse modulation WAV stream. Based of Gilles De Mey's node-record-lpcm16.

Installation

npm install node-audiorecorder

Dependencies

This module requires you to install SoX and it must be available in your $PATH.

For Linux

sudo apt-get install sox libsox-fmt-all

For MacOS

brew install sox

For Windows

Download the binaries

Usage

Constructor

// Import module.
const AudioRecorder = require('node-audiorecorder')

// Options is an optional parameter for the constructor call.
// If an option is not given the default value, as seen below, will be used.
const options = {
  program: `rec`, // Which program to use, either `arecord`, `rec`, or `sox`.
  device: null, // Recording device to use, e.g. `hw:1,0`

  bits: 16, // Sample size. (only for `rec` and `sox`)
  channels: 1, // Channel count.
  encoding: `signed-integer`, // Encoding type. (only for `rec` and `sox`)
  format: `S16_LE`, // Encoding type. (only for `arecord`)
  rate: 16000, // Sample rate.
  type: `wav`, // Format type.

  // Following options only available when using `rec` or `sox`.
  silence: 2, // Duration of silence in seconds before it stops recording.
  thresholdStart: 0.5, // Silence threshold to start recording.
  thresholdStop: 0.5, // Silence threshold to stop recording.
  keepSilence: true, // Keep the silence in the recording.
}
// Optional parameter intended for debugging.
// The object has to implement a log and warn function.
const logger = console

// Create an instance.
let audioRecorder = new AudioRecorder(options, logger)

If you can't capture any sound with 'arecord' try to running 'arecord -l' to which devices are available.

See the arecord documentation for more detail on its options.

See the sox documentation for more detail on the rec and sox options.

Methods

// Creates and starts the recording process.
audioRecorder.start()
// Stops and removes the recording process.
audioRecorder.stop()
// Returns the stream of the recording process.
audioRecorder.stream()

Examples

See the examples directory for example usage.

For another example see the node-hotworddetector module, or Electron-VoiceInterfaceBoilerplate's input.js.

Troubleshooting

Windows continues recording

If you have issues with continues recording on Windows 10 with SoX 14.4.2 or later, install version 14.4.1 instead.

License

MIT license