You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

sox

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sox

node.js interface to the sox audio utility


Version published
Weekly downloads
302
decreased by-27.92%
Maintainers
1
Install size
12.2 kB
Created
Weekly downloads
 

Readme

Source

Installation

  • Requires sox CLI to be installed. This can be installed via most linux distribution's package managers.
  • npm install --save sox

Usage

identify an audio file

var sox = require('sox');

sox.identify('somefile.wav', function(err, results) {
  /* results looks like:
  {
    format: 'wav',
    duration: 1.5,
    sampleCount: 66150,
    channelCount: 1,
    bitRate: 722944,
    sampleRate: 44100,
  }
  */
});

transcode an audio file

var sox = require('sox');

// these options are all default, you can leave any of them off
var job = sox.transcode('source.wav', 'dest.mp3', {
  sampleRate: 44100,
  format: 'mp3',
  channelCount: 2,
  bitRate: 192 * 1024,
  compressionQuality: 5, // see `man soxformat` search for '-C' for more info
});
job.on('error', function(err) {
  console.error(err);
});
job.on('progress', function(amountDone, amountTotal) {
  console.log("progress", amountDone, amountTotal);
});
job.on('src', function(info) {
  /* info looks like:
  {
    format: 'wav',
    duration: 1.5,
    sampleCount: 66150,
    channelCount: 1,
    bitRate: 722944,
    sampleRate: 44100,
  }
  */
});
job.on('dest', function(info) {
  /* info looks like:
  {
    sampleRate: 44100,
    format: 'mp3',
    channelCount: 2,
    sampleCount: 67958,
    duration: 1.540998,
    bitRate: 196608,
  }
  */
});
job.on('end', function() {
  console.log("all done");
});

Keywords

FAQs

Package last updated on 09 Apr 2013

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc