How to Convert MP3 Files to WAV in JavaScript

Cloudmersive
2 min readApr 6, 2021

--

Converting audio files to different formats can sometimes be a cumbersome project to take on. However, in this article we will discuss how you can use an API in JavaScript to simplify the task of automatically detect the original format, such as MP3, and convert it to the sizable but quality WAV format. The operation uses 1 API call per additional minute of processing time over 5 minutes, and 1 API call per 10 MB of file size.

Our first step is to install the jQuery library by running this command:

bower install jquery

Next, we can call the conversion function with the following code:

var form = new FormData();
form.append("inputFile", fileInput.files[0], "file");
var settings = {
"url": "https://api.cloudmersive.com/video/convert/to/wav",
"method": "POST",
"timeout": 0,
"headers": {
"fileUrl": "<string>",
"sampleRate": "<number>",
"Content-Type": "multipart/form-data",
"Apikey": "YOUR-API-KEY-HERE"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
$.ajax(settings).done(function (response) {
console.log(response);
});

And that’s all! The returned result will be your brand new WAV file; it is important to note that the maximum output is capped at 50 GB of file size. To retrieve your personal API key, head over to the Cloudmersive website to register for a free account; this will give you access to 800 monthly calls across our entire library of APIs.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet