# node-audiorecorder

> Record audio via node using SoX or Arecord.

Latest version **3.0.0** (published 2022-02-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-audiorecorder
pnpm add node-audiorecorder
yarn add node-audiorecorder
bun add node-audiorecorder
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2022-02-14 |
| First published | 2017-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 102 |
| Author | Ron Dekker |
| Maintainers | redkenrok |
| Keywords | audio, recording, sox, rec, arecord, wav, wave |

## Links

- npm: https://www.npmjs.com/package/node-audiorecorder
- Repository: https://github.com/RedKenrok/node-audiorecorder
- Homepage: https://github.com/RedKenrok/node-audiorecorder#readme
- Issues: https://github.com/RedKenrok/node-audiorecorder/issues
- npm.io page: https://npm.io/package/node-audiorecorder

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2022-02-14
- 1.4.0 (next) — 2018-12-27
- 2.2.0 — 2020-06-20
- 2.0.1 — 2020-04-28
- 2.0.0 — 2020-02-16
- 1.4.2 — 2019-12-29
- 1.4.1 — 2019-03-13
- 1.3.0-beta.0 — 2018-12-12
- 1.2.0 — 2018-11-09
- 1.1.6 — 2018-11-08
- 1.1.5 — 2018-10-24
- 1.1.4 — 2018-10-23
- 1.1.3 — 2018-09-18
- 1.1.2 — 2018-06-25
- 1.1.1 — 2018-01-15
- … 10 more at https://npm.io/package/node-audiorecorder/versions

## README

<div align="center">

[![npm package @latest](https://img.shields.io/npm/v/node-audiorecorder.svg?label=npm@latest&style=flat-square&maxAge=3600)](https://npmjs.com/package/node-audiorecorder)
[![License agreement](https://img.shields.io/github/license/redkenrok/node-audiorecorder.svg?style=flat-square&maxAge=86400)](https://github.com/redkenrok/node-audiorecorder/blob/master/LICENSE)
[![Open issues on GitHub](https://img.shields.io/github/issues/redkenrok/node-audiorecorder.svg?style=flat-square&maxAge=86400)](https://github.com/redkenrok/node-audiorecorder/issues)

</div>

# Audio recorder

Audio recorder for [Node.js](https://nodejs.org/), delivers a 16-bit signed-integer linear pulse modulation WAV stream. Based of [Gilles De Mey](https://github.com/gillesdemey)'s [node-record-lpcm16](https://github.com/gillesdemey/node-record-lpcm16).

## Installation

```
npm install node-audiorecorder
```

## Dependencies

This module requires you to install [SoX](http://sox.sourceforge.net/) and it must be available in your \$PATH.

### For Linux

```
sudo apt-get install sox libsox-fmt-all
```

### For MacOS

```
brew install sox
```

### For Windows

[Download the binaries](http://sourceforge.net/projects/sox/files/latest/download)

## Usage

### Constructor

```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`.
  device: null, // Recording device to use, e.g. `hw:1,0`

  bits: 16, // Sample size. (only for `rec` and `sox`)
  channels: 1, // Channel count.
  encoding: `signed-integer`, // Encoding type. (only for `rec` and `sox`)
  format: `S16_LE`, // Encoding type. (only for `arecord`)
  rate: 16000, // Sample rate.
  type: `wav`, // 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](https://linux.die.net/man/1/arecord) for more detail on its options.

> See the [sox documentation](http://sox.sourceforge.net/Docs/Documentation) for more detail on the rec and sox options.

### Methods

```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()
```

### Examples

See the [examples directory](https://github.com/RedKenrok/node-audiorecorder/tree/master/examples) for example usage.

> For another example see the [node-hotworddetector](https://github.com/RedKenrok/node-hotworddetector) module, or [Electron-VoiceInterfaceBoilerplate](https://github.com/RedKenrok/Electron-VoiceInterfaceBoilerplate)'s input.js.

## Troubleshooting

### Windows continues recording

If you have issues with continues recording on Windows 10 with SoX 14.4.2 or later, install version [14.4.1](https://sourceforge.net/projects/sox/files/sox/14.4.1/) instead.

## License

[MIT license](https://github.com/redkenrok/node-audiorecorder/blob/master/LICENSE)

---
_Source: https://npm.io/package/node-audiorecorder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
