Transfer audio streams using WebRTC and Websocket
npm install audio-recorders
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()
})
this.recorder.onStreamProcessor = (buffer) => {
Websocket.send(buffer)
}
- exportAudio: wav // If you want to export wav audio
Start the recording
Stop the recorder
Clean up the last recording cache
Receiving audio stream, The size of each chunk is about 3084
onStreamProcessor(streamBuffers => () {})
Blob file generated after audio recording is complete
onReceiveAudioBlob(audioBuffers => {})
You must configure the exportAudio: wav
value to execute this method