Web Audio API - record to MP3?

前端 未结 6 1097
感情败类
感情败类 2021-02-01 06:06

I am asking because I couldn\'t find the answer anywhere. I have successfully implemented RecorderJS in order to record microphone input in JS. However, the recorded file is WAV

6条回答
  •  执念已碎
    2021-02-01 06:41

    I was frustrated with this problem, and existing solutions, so I came up with something simpler:

    https://github.com/sb2702/audioRecord.js

    Usage

    Create a recorder object (async because requires user permission)

        Recorder.new(function(recorder){ 
    
        }); 
    

    Start recording

             recorder.start();        
    

    Stops recording

             recorder.stop();    
    

    Export as mp3

             recorder.exportMP3(function(mp3Blob){ 
    
                console.log("Here is your blob: " + URL.createObjectURL(mp3Blob));
    
              });
    

    Mostly based on RecorderJS, but changed some things around to export to mp3 files, and to not have to muck around with AudioContext / navigator.getUs

提交回复
热议问题