Registry / http-networking / node-audiorecorder

node-audiorecorder

JSON →
library3.0.0jsnpmunverified

node-audiorecorder is a Node.js module designed for recording audio, delivering a 16-bit signed-integer linear pulse modulation WAV stream. It acts as a wrapper around external system utilities like SoX ('rec' or 'sox' commands) or ALSA's 'arecord' utility, which must be installed and available in the system's PATH. This package is currently at version 3.0.0 and offers robust control over recording parameters such as sample rate, bit depth, channels, encoding, and silence detection. Its primary differentiator is providing a programmatic interface to common command-line audio recording tools, making it suitable for applications requiring real-time audio input processing or storage. While its release cadence appears sporadic based on recent releases, the latest major version indicates ongoing maintenance and improvements.

npm install node-audiorecorder
INSTALL
IMPORT
SIG · NODE-AUDIORECORDER
N
node-audiorecorder
http-networkingjavascriptv3.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AudioRecorder
const AudioRecorder = require('node-audiorecorder')
import AudioRecorder from 'node-audiorecorder'
The README and examples primarily show CommonJS `require`. While ESM might be supported, CommonJS is the demonstrated approach for direct instantiation.
options object
const options = { /* ... */ }
import { options } from 'node-audiorecorder'
Configuration options are passed directly to the constructor as an object, not imported as named exports from the module.

This quickstart demonstrates how to initialize the AudioRecorder, start a recording session, and pipe the output stream to a WAV file. It includes necessary external dependency setup comments and error handling.

const AudioRecorder = require('node-audiorecorder'); const fs = require('fs'); const path = require('path'); // IMPORTANT: Ensure SoX or Arecord is installed on your system // For Linux: sudo apt-get install sox libsox-fmt-all // For MacOS: brew install sox // For Windows: Download binaries from sox.sourceforge.net const outputFilePath = path.join(__dirname, 'output.wav'); const options = { program: `rec`, // Try `arecord` if on Linux and `rec` doesn't work device: null, // Set e.g. `hw:1,0` if you have multiple devices bits: 16, channels: 1, encoding: `signed-integer`, format: `S16_LE`, rate: 16000, type: `wav`, silence: 5, // Stop recording after 5 seconds of silence thresholdStart: 0.5, thresholdStop: 0.5, keepSilence: true }; const logger = console; // Optional: for debugging const audioRecorder = new AudioRecorder(options, logger); // Create a write stream to save the audio to a file const fileStream = fs.createWriteStream(outputFilePath, { encoding: 'binary' }); // Pipe the audio stream to the file audioRecorder.stream().pipe(fileStream); console.log('Starting audio recording... (will stop after 10 seconds or 5s silence)'); audioRecorder.start(); // Stop recording after 10 seconds for demonstration setTimeout(() => { audioRecorder.stop(); console.log(`Recording stopped. Audio saved to ${outputFilePath}`); fileStream.end(); }, 10000); // Handle errors from the recording process audioRecorder.on('error', (err) => { console.error('Recording error:', err); });
Debug
Known issues
breakingThis module is a wrapper around system utilities (SoX/arecord). These external tools are not bundled and must be manually installed and present in the system's PATH for node-audiorecorder to function.
fix
Install SoX (sudo apt-get install sox libsox-fmt-all on Linux, brew install sox on macOS, download binaries for Windows) or ensure 'arecord' is available on Linux systems.
affects: >=1.0.0
gotchaOn Windows 10, using SoX version 14.4.2 or later can lead to issues with continuous recording that does not stop correctly.
fix
For Windows users, downgrade SoX to version 14.4.1 to avoid continuous recording issues. This is a known compatibility problem with specific SoX versions.
affects: >=14.4.2 (SoX)
gotchaIncorrect or unavailable audio device selection can prevent recording or result in silence. The `device` option might need to be explicitly set.
fix
For `arecord`, run `arecord -l` to list available devices and specify the correct device string (e.g., `hw:1,0`) in the `options.device` parameter. Consult SoX/arecord documentation for device enumeration.
affects: >=1.0.0
Errors
Common errors & fixes
Error: spawn sox ENOENT
The 'sox' command (or 'rec' which is part of SoX) is not found in the system's PATH.
fix
Ensure SoX is installed on your operating system and its executable directory is included in your system's PATH environment variable.
Error: spawn arecord ENOENT
The 'arecord' command is not found in the system's PATH, or ALSA utilities are not installed.
fix
Ensure ALSA utilities are installed (e.g., `sudo apt-get install alsa-utils` on Debian/Ubuntu) and 'arecord' is available in your PATH. Consider using `program: 'rec'` if SoX is installed.
Warning: 'silence' ignored for program 'arecord'.
The `silence`, `thresholdStart`, `thresholdStop`, and `keepSilence` options are only available when using `rec` or `sox` programs, not `arecord`.
fix
Switch `options.program` to `rec` or `sox` if you require silence detection features. If using `arecord`, you will need to implement silence detection logic separately.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
SoXrequiredRequired for audio recording on most systems; provides 'rec' or 'sox' commands.
ALSA (arecord)optionalAlternative to SoX for audio recording, primarily on Linux systems.
libsox-fmt-alloptionalLinux-specific dependency for SoX to ensure support for various audio formats.
Agent activity
2 hits · last 30 days
node
2
Resources
node-audiorecorder — npm install node-audiorecorder · libregistry