0

Trying to capture raw audio from a user using recorder.js and upload it to a server, I came across this site and it instructed to call function stopRecording() with a second argument and also to change _AudioFormat from "audio/wav" to "audio/mpeg".

Code snippet from my view:

$(".transBtn").click(function(){
            if($(this).hasClass("transRecording")){
                //var _AudioFormat = "audio/mp3";

                var AudioFormat = "audio/mpeg";

                stopRecording(function(AudioBLOB){

                    var url = URL.createObjectURL(AudioBLOB);


                    $(".downloadAud").attr("href" , url);
                    $(".downloadAud").attr("download" , "myRec.mp3");

                    var l = document.getElementById('save');  // save is the id of anchor tag
                    l.click();
                }, AudioFormat);
            }
            else {
                startRecording();
                //alert("Live Recording");
            }
        })

Sorry to take your time but I'm unable to download the file in .mp3 format. I would be very glad if you helped.

Thanks in advance.

handlerFive
  • 870
  • 10
  • 23
  • 1
    That site is wrong. Recorder.js can only record pcm/wav audio. This (duplicate) question already has an answer [here](https://stackoverflow.com/a/50931101/813988) including mp3 encoding solutions. – octavn Jul 10 '18 at 17:11
  • 1
    Possible duplicate of [How to record audio in format of mp3/m4a JavaScript- recorder.js](https://stackoverflow.com/questions/32138865/how-to-record-audio-in-format-of-mp3-m4a-javascript-recorder-js) – octavn Jul 10 '18 at 17:13

0 Answers0