how to decode base64 audio data to wav format

2.9k views Asked by At

I am recording audio in browser and wanted to save that recording on server using ajax call.

I have used recorderjs library for recording in html5 browser and its working as well.

So what I want to do is just to decode that blob/base64 data so that I can send that data to server to save. Here is my code.

I have converted blob data to base64

    var reader = new FileReader();
                    reader.onload = function() {

                        var dataUrl = reader.result;
                        var base64 = dataUrl.split(',')[1];
/*base64 this needs to be decoded*/

                    };
                    reader.readAsDataURL(blob);
                });
1

There are 1 answers

1
pratik nagariya On BEST ANSWER

Instead of using base64 string I have used "dataUrl" from my code and storing this "dataUrl" data to server using Ajax.

So whenever I want to play my recorded audio i just simply get the data using ajax and response data will be added in audio source like the below code.

var audio_obj = new Audio();
audio_obj = data; //ajax response data
audio_obj.play();