@itsalb3rt/wavefly

1.2.1 • Public • Published

Wavefly

Transcode any audio file to wav with minimal effort. This library is an abstraction to facilitate the use of sox with node.

Get started

From this point I will assume that you are using linux

Install SOX comand line utility

$ sudo apt update
$ sudo apt install sox
# support all formats like mp3, ogg, flac
$ sudo apt install libsox-fmt-all

Basic use

$ npm i @itsalb3rt/wavefly

Example

const wavefly = require('@itsalb3rt/wavefly');

// test
const inputFilePath = './example_audio/source6.flac';
const outputFilePath = './example_audio/out_audio/out.wav';

const result = wavefly(inputFilePath, outputFilePath);

result.then(response => {
    console.log('promisse resolved')

    response.on('end', () => {
        console.log('Audio transcoding!')
    })

})

⚠️ Note that the promise resolution does not indicate that the file has already been processed, for this you must use the response, an event called end

More options

Optionally you can specify the following parameters;

/**
 * @param {string} inputFilePath: path of input audio ./src/example_audio/source6.flac
 * @param {string} outputFilePath: path of output audio ./src/example_audio/out_audio/out.wav
 * @param {string} outputFileType: by default 'wav'
 * @param {Integer} outputSampleRate Set the sample rate in Hz (or kHz if appended with a 'k')
 * @param {Integer} outputChannels by default in 1 (mono)
 */
function wavefly(inputFilePath, outputFilePath, outputFileType = 'wav', outputSampleRate = 8000, outputChannels = 1 ){}

Help Links

Readme

Keywords

none

Package Sidebar

Install

npm i @itsalb3rt/wavefly

Weekly Downloads

1

Version

1.2.1

License

ISC

Unpacked Size

3 MB

Total Files

15

Last publish

Collaborators

  • itsalb3rt