Explaination
-
a realtime audio recorder, it can generate
pcm
ormp3
buffer of audio data with configurable sample rate and bit depth. -
when recording, it start a web worker thread in the browser to transform the
bitDepth
andsampleRate
, so it's very fast in realtime -
please remember to using this package under
https
, or it won't work
Usage
; { if !Recorder this else recorder = recordingGain: numberOfChannels: 1 // this is suggested wavBitDepth: 16 format: 'mp3' // default to pcm, which is larger wavSampleRate: 16000 streamPages: true // we can get the buffer stream in realtime in the ondataavailable callback recorder { console; } recorder { this } thisrecorder { if datacommand === 'buffer' this; // 片段数据,bufferLength的大小 else if datacommand === 'wav' const dataBlob = typedArray type: 'audio/wav' const url = URL thisaudioSrc = url } recorderstart; }
Optional Configuration
-
bufferLength - (optional) default to
4096
, which means when theondataavailable
function called, the size of response buffer will be4096
-
monitorGain - (optional) set the echo of your recording, the value range is
0-1
, default to0
, which means mute the echo -
numberOfChannels - (optional) 1 or 2, 1 is suggested
-
recordingGain - (optional) the volume of your voice, the value range is
0-1
, default to1
-
wavBitDepth - (optional) the bit length of the recordered buffer, default is
16
, you can set it to8
,16
,24
,32