Search code examples
react-nativereact-native-web

How to record voice using react native web?


Is there a way to record and play audio using react native web? I have been looking for some resources but I wasn't able to find any.


Solution

  • Checkout the following npm library:

    https://github.com/jsierles/react-native-audio

    A simple example how to use this module.

    import {AudioRecorder, AudioUtils} from 'react-native-audio';
    let audioPath = AudioUtils.DocumentDirectoryPath + '/test.aac';
    
    AudioRecorder.prepareRecordingAtPath(audioPath, {
      SampleRate: 22050,
      Channels: 1,
      AudioQuality: "Low",
      AudioEncoding: "aac"
    });
    

    In order to play back sound you could then use the following:

    https://github.com/zmxv/react-native-sound