node-microphone
node-microphone copied to clipboard
Consider removing mp3 encoding?
Hi,
I'm trying to use this on a raspberry pi, but it won't install because of the lame dependency (https://github.com/TooTallNate/node-lame/issues/58). However, I don't actually need mp3 encoding, just wav will do. I can edit the module myself to remove lame and it does work then, but I thought I'd mention it here. Would you consider one of the following?
- Split this into two modules: microphone and mp3-microphone OR
- Move the mp3 part out of the core and into an example
I think either of those options would be more in line with the node/unix philosophy of small modules that do one thing and do it well.
:+1:
:+1: Was gonna use this for a project on the raspberry pi, but it failed to install even locally because of lame, looked in the issues and found this. Double whammy.
Looks like there are two pull requests, older and newer trying to update lame to fix compatibility with new node versions. Luckily the module can be expressed in 30 LOC (or 20), so I went a different route:
is_Mac_or_Windows = require('os').type().match(/Darwin|Windows/)
{spawn} = require('child_process')
{PassThrough} = require('stream')
child_process = null
audio = new PassThrough
info = new PassThrough
start = ->
return if child_process?
child_process =
if is_Mac_or_Windows
spawn('sox', ['-d', '-t', 'dat', '-p'])
else
spawn('arecord', ['-D', 'plughw:1,0', '-f', 'dat'])
child_process.stdout.pipe(audio)
child_process.stderr.pipe(info)
stop = ->
child_process?.kill()
child_process = null
exports.audioStream = audio
exports.infoStream = info
exports.startCapture = start
exports.stopCapture = stop
Nice work. That's about what I did, but your's is much cleaner.
@vincentsaluzzo you should just give @1j01 commit & npm publish permissions and call it a day ;)
(Or I'd be willing to take it over if he wasn't interested.)