
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
lambda-audio
Advanced tools
Run Sound eXchange (SoX), the Swiss Army knife of audio manipulation, with Lame on AWS Lambda.
Run Sound eXchange (SoX), the Swiss Army knife of audio manipulation, with Lame on AWS Lambda.
lambda-audio is static binary of sox utility, built for AWS Lambda. It supports sox, soxi and lame commands.
lambda-audio allows you to covert and merge multiple audio files using AWS Lambda.
You can use it as a replacement/cheaper version of Amazon Elastic Transcoder. Or you can use it for the workflows that are not currently possible on Elastic Transcoder.
Motivation behind this library was a use case where we had up to five audio file that needs to be merged with specific rules — we need to put music in the background and different pauses between voice files. Service is used only from time to time, but we had instance for node.js app running all the time. This library is trying to solve that problem and allow us to do merging and conversion in AWS Lambda.
You can install this package from NPM by running following command:
npm install lambda-audio --save
After you require node module in your code by adding:
const lambdaAudio = require('lambda-audio')
lambdaAudio will contain three functions:
Each of the functions receives 1 argument that can be the string that contains the command or an array of attributes that needs to be passed to the command.
Each function is returning promise that will resolve when the command is successfully executed or has an error. Success answers will go to .then statement, errors will go to .catch statement. Response for both success and error will be passed as a string argument.
See below for the examples.
Let's say that you want to convert input.mp3 file to mono, and output it as output.wav file, in command line you would do that like this:
sox input.mp3 -c 1 output.wav
With lambda-audio you can do that by passing the command as a string, just without sox part, like this:
lambdaAudio.sox('./input.mp3 -c 1 /tmp/output.wav')
.then(response => {
// Do something when the file was converted
})
.catch(errorResponse => {
console.log('Error from the sox command:', errorResponse)
})
Or by passing the arguments as an array:
lambdaAudio.sox(['./input.mp3', '-c', '1', '/tmp/output.wav'])
.then(response => {
// Do something when the file was converted
})
.catch(errorResponse => {
console.log('Error from the sox command:', errorResponse)
})
Keep in mind that AWS Lambda is read only and that the output path needs to be in /tmp folder.
For the full list of options, visit sox documentation.
Let's say that you want to see the info about input.mp3 file, in command line you would do that like this:
soxi input.mp3
With lambda-audio you can do that by passing the command as a string:
lambdaAudio.soxi('./input.mp3')
.then(response => {
// Do something with the info
})
.catch(errorResponse => {
console.log('Error from the soxi command:', errorResponse)
})
Or by passing the arguments as an array:
lambdaAudio.soxi(['./input.mp3'])
.then(response => {
// Do something with the info
})
.catch(errorResponse => {
console.log('Error from the soxi command:', errorResponse)
})
For the full list of options, visit soxi documentation.
Let's say you want to re-encode existing MP3 to 64 kbps MP3, in command line you would do it like this:
lame -b 64 input.mp3 output.mp3
With lambda-audio you can do that by passing the command as a string:
lambdaAudio.lame('-b 64 ./input.mp3 /tmp/output.mp3')
.then(response => {
// Do something with the new mp3 file
})
.catch(errorResponse => {
console.log('Error from the lame command:', errorResponse)
})
Or by passing the arguments as an array:
lambdaAudio.lame(['-b', '64', './input.mp3', '/tmp/output.mp3'])
.then(response => {
// Do something with the new mp3 file
})
.catch(errorResponse => {
console.log('Error from the lame command:', errorResponse)
})
For the full list of options, visit lame documentation.
lambda-audio is working perfectly with Claudia.js library, but you can use it with other AWS Libraries and frameworks too.
With Claudia.js, simply save lambda-audio as a dependency and then you can deploy your AWS Lambda function using standard claudia create command.
We use Jasmine for unit and integration tests. Unless there is a very compelling reason to use something different, please continue using Jasmine for tests. The existing tests are in the spec folder. Here are some useful command shortcuts:
Run all the tests:
npm test
Run only some tests:
npm test -- filter=prefix
Get detailed hierarchical test name reporting:
npm test -- full
GNU GENERAL PUBLIC LICENSE, Version 2 -- see LICENSE
FAQs
Run Sound eXchange (SoX), the Swiss Army knife of audio manipulation, with Lame on AWS Lambda.
We found that lambda-audio demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.