Package Exports
- convert-audio
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (convert-audio) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
convert-audio
A lightweight audio conversion tool to convert mp3, wav and aac file.
DEMO
Install
npm install convert-audio
Usage
import AudioConverter from 'convert-audio'
AudioConverter.convert(sourceAudioFile, targetAudioFormat);
Example Code
<input type='file' accept=".mp3, .wav, .aac" onchange="convertAudio(this)" />
import AudioConverter from 'convert-audio'
async function convertAudio(input) {
let sourceAudioFile = input.files[0];
let targetAudioFormat = 'wav'
let convertedAudioDataObj = await AudioConverter.convert(sourceAudioFile, targetAudioFormat);
}
This convert function will return a converted audio data object which includes audio name, format and blob URL.
This blob URL can be used to download the converted audio.
function downloadAudio(convertedAudioDataObj) {
let a = document.createElement("a");
a.href = convertedAudioDataObj.data;
a.download = convertedAudioDataObj.name + "." + convertedAudioDataObj.format;
a.click();
}
License
MIT