Record audio via node using SoX or Arecord.
npm install node-audiorecorder


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.
```
npm install node-audiorecorder
This module requires you to install SoX and it must be available in your \$PATH.
``
sudo apt-get install sox libsox-fmt-all
``
brew install sox
`javascript
// 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.hw:1,0
device: null, // Recording device to use, e.g.
bits: 16, // Sample size. (only for rec and sox)signed-integer
channels: 1, // Channel count.
encoding: , // Encoding type. (only for rec and sox)S16_LE
format: , // Encoding type. (only for arecord)wav
rate: 16000, // Sample rate.
type: , // 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.
`javascript``
// 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()
See the examples directory for example usage.
> For another example see the node-hotworddetector module, or Electron-VoiceInterfaceBoilerplate's input.js.
If you have issues with continues recording on Windows 10 with SoX 14.4.2 or later, install version 14.4.1 instead.