audio - How to play wav file in Node.Js? -


i need simple: play audio file node.js file. i've tried sorts of things , cannot find works. i'm trying "play-sound", link: https://www.npmjs.com/package/play-sound

i made sure install play-sound, , have following code:

var player = require('play-sound')(opts = {}) player.play('chime.wav', function(err){ if (err) throw err }); 

i nothing. can play sound fine command line with:

aplay chime.wav 

any ideas appreciated.

update: figured out. "node-aplay" worked me: https://www.npmjs.com/package/node-aplay

i didn't need usb audio configuration part. installed node-aplay , alsa according instructions. code first 2 lines in example:

var sound = require('node-aplay');  // fire , forget:  new sound('/path/to/the/file/filename.wav').play(); 

you see happening checking stdout or stderr:

var player = require('play-sound')(opts = {}) var player.play('chime.wav', function(err, stdout, stderr) {    if (err) throw err    console.log(stdout)                                                                                                   console.log(stderr) }); 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -