Play audio with Node.JS


Question

I'm currently using child_process and command-line mplayer to play audio on the local machine, with my Node.JS application. This works, but it's not really an excellent solution. My biggest issue is that it takes 500ms from mplayer is started to audio starts playing.

Are there better ways to play audio? Preferably compressed audio, but I'll take what I can get.

1
23
9/22/2012 11:14:08 AM

Accepted Answer

I think what you asking is there any good modules that work with audio in the nodejs ecosystem?

Whenever you have this type of question you should first go the npmjs and just type a appropiate keyword.

Here is list of modules that related to audio I found on the npmjs site.

substacks's baudio looks good to me.

5
9/22/2012 11:57:59 AM

I would suggest using node-speaker, which outputs raw PCM data to your speakers (so basically, it plays audio).

If you're playing something like mp3 files you might need to decode it first to PCM data, which is exactly what node-lame does.

Hope that helps.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon