{"library":"node-audiorecorder","title":"Node.js Audio Recorder","description":"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.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install node-audiorecorder"],"cli":null},"imports":["const AudioRecorder = require('node-audiorecorder')","const options = { /* ... */ }"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const AudioRecorder = require('node-audiorecorder');\nconst fs = require('fs');\nconst path = require('path');\n\n// IMPORTANT: Ensure SoX or Arecord is installed on your system\n// For Linux: sudo apt-get install sox libsox-fmt-all\n// For MacOS: brew install sox\n// For Windows: Download binaries from sox.sourceforge.net\n\nconst outputFilePath = path.join(__dirname, 'output.wav');\n\nconst options = {\n  program: `rec`, // Try `arecord` if on Linux and `rec` doesn't work\n  device: null,   // Set e.g. `hw:1,0` if you have multiple devices\n  bits: 16,\n  channels: 1,\n  encoding: `signed-integer`,\n  format: `S16_LE`,\n  rate: 16000,\n  type: `wav`,\n  silence: 5, // Stop recording after 5 seconds of silence\n  thresholdStart: 0.5,\n  thresholdStop: 0.5,\n  keepSilence: true\n};\n\nconst logger = console; // Optional: for debugging\n\nconst audioRecorder = new AudioRecorder(options, logger);\n\n// Create a write stream to save the audio to a file\nconst fileStream = fs.createWriteStream(outputFilePath, { encoding: 'binary' });\n\n// Pipe the audio stream to the file\naudioRecorder.stream().pipe(fileStream);\n\nconsole.log('Starting audio recording... (will stop after 10 seconds or 5s silence)');\n\naudioRecorder.start();\n\n// Stop recording after 10 seconds for demonstration\nsetTimeout(() => {\n  audioRecorder.stop();\n  console.log(`Recording stopped. Audio saved to ${outputFilePath}`);\n  fileStream.end();\n}, 10000);\n\n// Handle errors from the recording process\naudioRecorder.on('error', (err) => {\n  console.error('Recording error:', err);\n});","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}