audio-recorders

1.1.9 • Public • Published

npm-audio-recorder

Build Status

Transfer audio streams using WebRTC and Websocket

Install

npm install audio-recorders

Example

Usually

  import AudioRecorders from 'audio-recorders'
  
   navigator.getUserMedia({audio: true}, (stream) => {
      const config = {
        exportAudio: 'wav'
      }
      
      this.recorder = new AudioRecorders(stream, config)
      
      this.recorder.onStreamProcessor = (buffer) => {}
      this.recorder.onReceiveAudioBlob = (blobs) => {}

      this.recorder.startRecord()
   })

With Websocket

    this.recorder.onStreamProcessor = (buffer) => {
        Websocket.send(buffer)
    }

Config

  1. exportAudio: wav // If you want to export wav audio

Methods

startRecord

Start the recording

stopRecord

Stop the recorder

clear

Clean up the last recording cache

Call back

onStreamProcessor

Receiving audio stream, The size of each chunk is about 3084

onStreamProcessor(streamBuffers => () {})

onReceiveAudioBlob

Blob file generated after audio recording is complete

onReceiveAudioBlob(audioBuffers => {}) You must configure the exportAudio: wav value to execute this method

Package Sidebar

Install

npm i audio-recorders

Weekly Downloads

4

Version

1.1.9

License

MIT

Unpacked Size

16.8 kB

Total Files

6

Last publish

Collaborators

  • haojenma