1.1.1 • Published 6 years ago

@scottishcyclops/node-recorder v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

node-recorder

A simple cross-platform audio recoding utility for node

It requires the installation of the command line utility rec, which is part of sox

Examples

Record audio, trimming the beginning and the end to audio.wav

const mic = require('@scottishcyclops/node-recorder')
const audio = require('@scottishcyclops/node-audio')
const { createWriteStream } = require('fs')

async function main()
{
  const audiofile = __dirname + '/audio.wav'
  const out = createWriteStream(audiofile, { flags: 'w+', encoding: 'binary' })

  const recorder = mic.start({ trimEnd: true })

  recorder.stdout.pipe(out)

  out.once('close', async () => {
    mic.stop(recorder)
    await audio.play(audiofile)
  })
}

main().catch(console.error)

Please report any bugs here