TooTallNate / node-speaker

Output PCM audio data to the speakers
655 stars 147 forks source link

Raspberry Pi 4 (Debian) node-gyp build fails #176

Open iQuickDev opened 1 year ago

iQuickDev commented 1 year ago
iquick@pi:~/WebTTS $ npm install speaker
npm ERR! code 1
npm ERR! path /home/iquick/WebTTS/node_modules/speaker
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@17.9.1 | linux | arm64
npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/iquick/WebTTS/node_modules/speaker/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/iquick/.cache/node-gyp/17.9.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/iquick/.cache/node-gyp/17.9.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/iquick/.cache/node-gyp/17.9.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/iquick/WebTTS/node_modules/speaker',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp: name 'mpg123_cpu' is not defined while evaluating condition 'mpg123_cpu=="arm_nofpu"' in deps/mpg123/mpg123.gyp while loading dependencies of binding.gyp while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 6.1.21-v8+
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/iquick/WebTTS/node_modules/speaker
npm ERR! gyp ERR! node -v v17.9.1
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/iquick/.npm/_logs/2023-07-16T00_20_10_188Z-debug-0.log

the problem seems to be the following:

npm ERR! gyp: name 'mpg123_cpu' is not defined while evaluating condition 'mpg123_cpu=="arm_nofpu"' in deps/mpg123/mpg123.gyp while loading dependencies of binding.gyp while trying to load binding.gyp

i don't know how to fix it but at least i think i found the issue

galaxieof commented 1 year ago

Hi, I have the same problem, do you have find the solution ?

iQuickDev commented 1 year ago

Hi, I have the same problem, do you have find the solution ?

yes, there is a package called speaker-arm64 on npm. Try that one instead

galaxieof commented 1 year ago

I have the same problem :'(

root@DietPi:/mnt/dietpi_userdata/node-red# npm install speaker-arm64 npm ERR! code 7 npm ERR! path /mnt/dietpi_userdata/node-red/node_modules/speaker-arm64 npm ERR! command failed npm ERR! command sh -c node-gyp rebuild npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.4.0 npm ERR! gyp info using node@12.13.0 | linux | arm64 npm ERR! gyp info find Python using Python version 3.11.2 found at "/usr/bin/python3" npm ERR! gyp ERR! UNCAUGHT EXCEPTION npm ERR! gyp ERR! stack /mnt/dietpi_userdata/node-red/node_modules/minipass-fetch/node_modules/minipass /dist/commonjs/index.js:286 npm ERR! gyp ERR! stack this.emit('abort', this[SIGNAL]?.reason); npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack npm ERR! gyp ERR! stack SyntaxError: Unexpected token '.' npm ERR! gyp ERR! stack at Module._compile (internal/modules/cjs/loader.js:892:18) npm ERR! gyp ERR! stack at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) npm ERR! gyp ERR! stack at Module.load (internal/modules/cjs/loader.js:812:32) npm ERR! gyp ERR! stack at Function.Module._load (internal/modules/cjs/loader.js:724:14) npm ERR! gyp ERR! stack at Module.require (internal/modules/cjs/loader.js:849:19) npm ERR! gyp ERR! stack at require (internal/modules/cjs/helpers.js:74:18) npm ERR! gyp ERR! stack at Object.<anonymous> (/mnt/dietpi_userdata/node-red/node_modules/minipass-fetch/lib /index.js:6:22) npm ERR! gyp ERR! stack at Module._compile (internal/modules/cjs/loader.js:956:30) npm ERR! gyp ERR! stack at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) npm ERR! gyp ERR! stack at Module.load (internal/modules/cjs/loader.js:812:32) npm ERR! gyp ERR! System Linux 6.1.21-v8+ npm ERR! gyp ERR! command "/mnt/dietpi_userdata/node-red/node_modules/node/bin/node" "/mnt/dietpi_userdata/node -red/node_modules/.bin/node-gyp" "rebuild" npm ERR! gyp ERR! cwd /mnt/dietpi_userdata/node-red/node_modules/speaker-arm64 npm ERR! gyp ERR! node -v v12.13.0 npm ERR! gyp ERR! node-gyp -v v9.4.0 npm ERR! gyp ERR! Node-gyp failed to build your package. npm ERR! gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author. `npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-10-25T10_39_08_876Z-debug-0.log`

Sengulair commented 11 months ago

Same problem, @galaxieof did you find any solution?

imsunburnt commented 11 months ago

Fix from @iQuickDev worked for me.
Running on Raspberry Pi 3B+ with 2023-12-05 Raspberry Pi OS 64 Bit Lite (Bullseye Lite 64 bit).
I did the following: `sudo apt-get install libasound2-dev npm install speaker-arm64

Then in my nodejs program: const Speaker = require("speaker-arm64") ` Testing with AWS Polly worked OK.

GimpMaster commented 9 months ago

Thanks for the speaker-arm64 suggestion, worked great with @flat/lame to play mp3s on the raspberry pi 4.

Minimal Code

var fs = require('fs');
var lame = require('@flat/lame');
var Speaker = require('speaker-arm64');

fs.createReadStream(process.argv[2])
    .pipe(new lame.Decoder())
    .on('format', function (format) {
        this.pipe(new Speaker(format));
    });