MediaStreamRecorder icon indicating copy to clipboard operation
MediaStreamRecorder copied to clipboard

Silence detection in audio (onspeaking and onsilence events)

Open borabilgin opened this issue 9 years ago • 7 comments

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!

borabilgin avatar Aug 28 '15 13:08 borabilgin

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;

muaz-khan avatar Aug 28 '15 13:08 muaz-khan

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.

borabilgin avatar Aug 28 '15 13:08 borabilgin

Silence detection feature is not added yet. BTW, yep, we can fire ondataavailable on detecting silence.

muaz-khan avatar Aug 28 '15 14:08 muaz-khan

Any updates about silence detector?

Premier avatar Oct 26 '17 16:10 Premier

How would we go about using ondataavailable to detect silences?

ItsWendell avatar Nov 29 '17 18:11 ItsWendell

Any hints how to achieve this?

adeel-raza avatar Dec 28 '17 13:12 adeel-raza

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 };

fookingthg avatar May 01 '18 09:05 fookingthg