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-audiorecorderVerified import paths — ran on the pinned version, not inferred.
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.
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.
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.
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.
Ensure SoX is installed on your operating system and its executable directory is included in your system's PATH environment variable.
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.
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.