MediaStreamRecorder
MediaStreamRecorder copied to clipboard
Silence detection in audio (onspeaking and onsilence events)
First of all, thanks for providing this library - it is a lifesaver!
The RTCMultiConnection library has silence detection, which I believe would be useful in MediaStreamRecorder. Instead of saving blobs on an interval (such as every 5 seconds), we can upload the blobs when the user stops speaking. Is this feature in the roadmap for this library (or is it easy to integrate)?
Thanks!
Here is how to get ondataavailable
event fired only on a button click:
mediaRecorder.start(999999999999999); // longest possible interval
document.getElementById('stop-recording').onclick = function() {
mediaRecorder.stop(); // stop on button click
};
E.g. http://stackoverflow.com/a/32264996/552182
BTW, silence detection can be added as an optional feature. E.g.
mediaRecorder.recorderType = StereoAudioRecorder; // force WebAudio for Edge/Firefox/Chrome
mediaRecorder.skipSilentAudioBuffers = true;
// or
mediaRecorder.dontRecordOnSilence = true;
What I meant was to make the blobs available when silence is detected - but thanks for the reply. I'll look into the dontRecordOnSilence option and modify the code accordingly.
Silence detection feature is not added yet. BTW, yep, we can fire ondataavailable
on detecting silence.
Any updates about silence detector?
How would we go about using ondataavailable to detect silences?
Any hints how to achieve this?
you can use the onmute event to detect silence. But this will work only if it is completely silent and no data is available from the recording devices.
stream.getVideoTracks()[0].onmute = function() { //TODO : Do something };