Closed LinusU closed 6 years ago
@LinusU works for me.
Linux x86_64 node v8.3.0
May be you should add the new option to the README.md
.
Great work!
Edit: you could also include how to address different sound cards:
hw1:0
: sound card 1 (second card), subdevice 0 (default device)
cat /proc/asound/cards
for sound card information in linux
I only have Linux, so I could only test the same that meldron has already tested.
I agree this should be documented in the readme. A link to this would be helpful for Linux users. For SoX the format for the device name is probably very different. So having that documented would be nice, too.
This is throwing errors and breaking when i try this branch out
@cache91 what errors are you getting?
It basically shows it cannot open device
@cache91 can you give us more information?
Which os, which node version, what device... Stuff like this
[../deps/mpg123/src/output/alsa.c:103] error: initialize_device(): rate 44100 not available, using 48000
{ audioFormat: 1,
endianness: 'LE',
channels: 1,
sampleRate: 16000,
byteRate: 32000,
blockAlign: 2,
bitDepth: 16,
signed: true }
events.js:182
throw er; // Unhandled 'error' event
^
Error: specified PCM format is not supported by "alsa" backend
at Speaker._open (/home/pi/speaker-test/node_modules/speaker/index.js:91:13)
at Speaker._write (/home/pi/speaker-test/node_modules/speaker/index.js:175:23)
at doWrite (/home/pi/speaker-test/node_modules/readable-stream/lib/_stream_writable.js:406:64)
at writeOrBuffer (/home/pi/speaker-test/node_modules/readable-stream/lib/_stream_writable.js:395:5)
at Speaker.Writable.write (/home/pi/speaker-test/node_modules/readable-stream/lib/_stream_writable.js:322:11)
at Reader.ondata (/home/pi/node_modules/readable-stream/lib/_stream_readable.js:572:20)
at emitOne (events.js:115:13)
at Reader.emit (events.js:210:7)
at readableAddChunk (/home/pi/node_modules/readable-stream/lib/_stream_readable.js:195:16)
at Reader.Readable.push (/home/pi/node_modules/readable-stream/lib/_stream_readable.js:162:10)
This is the error that I am getting. The first console.log is the format that I am passing. I was not getting this problem with the master branch
reader.on('format', function (format) {
console.log(format);
speaker1 = new Speaker({
device:'plughw0:0',
audioFormat: 1,
endianness: 'LE',
channels: 1,
sampleRate: 16000,
byteRate: 32000,
blockAlign: 2,
bitDepth: 16,
signed: true});
reader.pipe( speaker1);
});
This is my code. Using raspbian OS on node 8.7.0
Sounds like a problem on your end. What happens if you use the same options with aplay on the command line?
@T-vK : the file plays on the command line after i save it. It seems so wierd. Also the fact that with the same hardware and setup , I am able to play using the package in master branch
@cache91 Hm, maybe it is a problem with this PR then. I have successfully used this project on raspbian before. I used the version that I forked some time ago. https://github.com/T-vK/node-speaker/tree/select-audio-device (the select-audio-device branch)
This code has worked for me on Raspbian: https://github.com/T-vK/tvoip/blob/master/audio-test.js It simply pipes the mic input to the speaker. I have used a Pi Zero W and thus I had to use a USB sound card btw.
Same as #91 and #104 but with some improvements:
ao->device
lifecycleI haven't been able to test this myself yet since I'm only on macOS...
ping @meldron, @MexXxo, @T-vK, @rhclayto; would you mind testing if this works? ❤️