How to Convert Audio to WAV in Node.JS

For larger sound files and a raw audio format, PC users looking to retain the highest quality of audio will choose the well-known WAV format for their needs. Their widespread use and capacity make WAV files the ideal audio format, particularly for those looking for professional quality sound recording. This Cloudmersive API will help you convert your audio files to WAV with ease.

Image for post
Image for post

Our first step is to install our client:

npm install cloudmersive-video-api-client --save

Or, add the following to your package.json:

"dependencies": {
"cloudmersive-video-api-client": "^2.0.1"
}

And then, we can call our function, AudioConvertToWav:

var CloudmersiveVideoApiClient = require('cloudmersive-video-api-client');
var defaultClient = CloudmersiveVideoApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveVideoApiClient.AudioApi();var opts = {
'inputFile': Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer), // File | Input file to perform the operation on.
'fileUrl': "fileUrl_example", // String | Optional; URL of an audio file being used for conversion. Use this option for files larger than 2GB.
'sampleRate': 8.14 // Number | Optional; Specify the desired sample rate of the converted audio file in kHz. Value may be between 8 and 96. Standard for audio CDs is 44.1, while DVD audio standard is 48. By default, the optimal sample rate will be chosen automatically.
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.audioConvertToWav(opts, callback);

Now, you can ensure that all of your audio meets the highest standards after converting to WAV.

Written by

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store