# react-native-audio-record

> Audio record buffers for React Native

Latest version **0.2.2** (published 2019-10-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-audio-record
pnpm add react-native-audio-record
yarn add react-native-audio-record
bun add react-native-audio-record
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2019-10-25 |
| First published | 2018-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 30 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 185 |
| Author | Vinay |
| Maintainers | vinayr |
| Keywords | react-native, audio, record |

## Links

- npm: https://www.npmjs.com/package/react-native-audio-record
- Repository: https://github.com/goodatlas/react-native-audio-record
- Homepage: https://github.com/goodatlas/react-native-audio-record#readme
- Issues: https://github.com/goodatlas/react-native-audio-record/issues
- npm.io page: https://npm.io/package/react-native-audio-record

## Recent versions

- 0.2.2 (latest) — 2019-10-25
- 0.2.1 — 2019-09-30
- 0.2.0 — 2019-01-12
- 0.1.3 — 2018-12-07
- 0.1.2 — 2018-06-20
- 0.1.1 — 2018-06-01
- 0.1.0 — 2018-04-21

## README

# react-native-audio-record
Audio record buffers for iOS and Android.

## Install
```
yarn add react-native-audio-record
react-native link react-native-audio-record
```

## Usage
```js
import AudioRecord from 'react-native-audio-record';

const options = {
  sampleRate: 16000,  // default 44100
  channels: 1,        // 1 or 2, default 1
  bitsPerSample: 16,  // 8 or 16, default 16
  audioSource: 6,     // android only (see below)
  wavFile: 'test.wav' // default 'audio.wav'
};

AudioRecord.init(options);

AudioRecord.start();

AudioRecord.stop();
// or to get the wav file path
audioFile = await AudioRecord.stop();

AudioRecord.on('data', data => {
  // base64-encoded audio data chunks
});
```

For `audioSource` use one of the constant values from [here](https://developer.android.com/reference/android/media/MediaRecorder.AudioSource). Default value is 6 (`VOICE_RECOGNITION`).

Use 3rd-party module like [buffer](https://www.npmjs.com/package/buffer) to decode base64 data. Example -
```js
// yarn add buffer
import { Buffer } from 'buffer';
chunk = Buffer.from(data, 'base64');
```
Don't forget to add microphone permission in your app.

## Example
`Example` folder contain sample apps for recording (using this module) and playback (using 3rd party modules)
- `App1.js` - uses [react-native-sound](https://github.com/zmxv/react-native-sound) for playback and pause
- `App2.js` - uses [react-native-video](https://github.com/react-native-community/react-native-video) for playback, pause and report progress
- `App3.js` - uses [react-native-audio-player-recorder](https://github.com/Shinetechchina/react-native-audio-player-recorder) for playback, pause and report progress

## Credits/References
I'm not a native app developer. Most of the code is taken from online resources.
- iOS [Audio Queues](https://developer.apple.com/library/content/documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide)
- Android [AudioRecord](https://developer.android.com/reference/android/media/AudioRecord.html)
- [cordova-plugin-audioinput](https://github.com/edimuj/cordova-plugin-audioinput)
- [react-native-recording](https://github.com/qiuxiang/react-native-recording)
- [SpeakHere](https://github.com/shaojiankui/SpeakHere)
- [ringdroid](https://github.com/google/ringdroid)

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