Search code examples
audio-recordinggetusermedia

Record audio into mutil-small block each duration with getUserMedia


I think I should begin with an example of what I want:

  1. User allow the web page to access mic, then start recording.
  2. Every 3 seconds (for example) capture what the user say (maybe into an Blob).
  3. Repeat until user want to stop.

I've found many example that use AudioContext.createScriptProcessor but it work by given a buffer size, I love to have similar thing but given a duration.


Solution

  • you can simply use recorderjs, and use it in the below mentioned fashion:

        var rec = new Recorder(source);
        rec.record();
        var recInterval = setInterval(function(){
            rec.exportWAV(function(blob){
                rec.clear();
                // do something with blob...           
            });
        }, 3000); // 3000 - to get blob for every three seconds.
    

    later on some button click, add rec.stop() to end .