I need something simple: play an audio file from my node.js file. I've tried all sorts of things and cannot find anything that works. I'm currently trying "play-sound", from this link: https://www.npmjs.com/package/play-sound
I made sure to install play-sound, and then I have just the following as my code:
var player = require('play-sound')(opts = {})
player.play('chime.wav', function(err){
if (err) throw err
});
I get nothing. I can play the sound just fine from the command line with:
aplay chime.wav
Any ideas would be appreciated.
Update: I figured it out. "node-aplay" worked for me: https://www.npmjs.com/package/node-aplay
I didn't need the USB audio configuration part. I just installed node-aplay and alsa according to the instructions. My code was just the first two lines in the example:
var Sound = require('node-aplay');
// fire and forget:
new Sound('/path/to/the/file/filename.wav').play();
Update: I figured it out. "node-aplay" worked for me: https://www.npmjs.com/package/node-aplay
I didn't need the USB audio configuration part. I just installed node-aplay and alsa according to the instructions. My code was just the first two lines in the example:
var Sound = require('node-aplay');
// fire and forget:
new Sound('/path/to/the/file/filename.wav').play();