@alifelived/react-native-audio-record
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

react-native-audio-record

Audio record buffers for iOS and Android.

Install

npm i react-native-audio-record
cd ios
pod install

Usage

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. Default value is 6 (VOICE_RECOGNITION).

Use 3rd-party module like buffer to decode base64 data. Example -

// yarn add buffer
import { Buffer } from 'buffer';
chunk = Buffer.from(data, 'base64');

Don't forget to add microphone permission in your app.

Credits/References

I'm not a native app developer. Most of the code is taken from online resources.

Package Sidebar

Install

npm i @alifelived/react-native-audio-record

Weekly Downloads

6

Version

1.1.1

License

MIT

Unpacked Size

46 kB

Total Files

15

Last publish

Collaborators

  • jameskemp
  • max_ckelly