Audio recorder for Node.js, Based of RedKenrok's node-audiorecorder.
npm install --save node-arecord
// Import module.
const Arecord = require('node-arecord');
// 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 = {
device: null, // Recording device to use.
channels: 2, // Channel count.
format: `S16_LE`, // Encoding type. (only for `arecord`)
rate: 48000, // Sample rate.
type: `wav`, // Format type.
};
// Optional parameter intended for debugging.
// The object has to implement a log and warn function.
const logger = console;
// Create an instance.
let audioIn = new Arecord(options, logger);
'arecord' will only work for linux based systems. If you can't capture any sound with 'arecord', try to change device to 'arecord -l'.
See the arecord documentation for more detail on its options.
// Creates and starts the recording process.
audioIn.start();
// Stops and removes the recording process.
audioIn.stop();
// Returns the stream of the recording process.
audioIn.stream();
See the examples directory for example usage.