Code Monkey home page Code Monkey logo

react-native-audio-record's Introduction

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

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.

Example

Example folder contain sample apps for recording (using this module) and playback (using 3rd party modules)

Credits/References

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

react-native-audio-record's People

Contributors

vinayr avatar qdjobson avatar is343 avatar actondev avatar jaybowang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.