cmusphinx / node-pocketsphinx

Pocketsphinx bindings for Node.JS
Other
242 stars 47 forks source link

The module PocketSphinx.node was compiled against a different Node.js version using NODE_MODULE_VERSION 48 #52

Closed 3id0 closed 6 years ago

3id0 commented 6 years ago

Hello,

When I call node-pocketsphinx's decoder, I get the following error:

Uncaught Error: The module '/Users/3id0/dev/muthex-test/node_modules/pocketsphinx/build/Release/PocketSphinx.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 48. This version of Node.js requires NODE_MODULE_VERSION 54. Please try re-compiling or re-installing the module (for instance, using npm rebuild ornpm install).", source: ELECTRON_ASAR.js

Here is my javascript file just in case:

var fs = require('fs');

var ps = require('pocketsphinx').ps;

modeldir = "../../pocketsphinx/model/en-us/"

var config = new ps.Decoder.defaultConfig();
config.setString("-hmm", modeldir + "en-us");
config.setString("-dict", modeldir + "cmudict-en-us.dict");
config.setString("-lm", modeldir + "en-us.lm.bin");
var decoder = new ps.Decoder(config);

const {desktopCapturer} = require('electron')

desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
  if (error) throw error
  for (let i = 0; i < sources.length; ++i) {
    if (sources[i].name === 'Electron') {
      navigator.mediaDevices.getUserMedia({
        audio: false,
        video: {
          mandatory: {
            chromeMediaSource: 'desktop',
            chromeMediaSourceId: sources[i].id,
            minWidth: 1280,
            maxWidth: 1280,
            minHeight: 720,
            maxHeight: 720
          }
        }
      }, handleStream, handleError)
      return
    }
  }
})

function handleStream (stream) {
  decoder.startUtt();
  decoder.processRaw(stream, false, false);
  decoder.endUtt();
  console.log(decoder.hyp())
}

function handleError (e) {
  console.log(e)
}

Is this a bug or am I doing something wrong?

I tried: ./node_modules/.bin/electron-rebuild ./node_modules/.bin/electron-rebuild -w pocketsphinx npm install --abi=54 npm install --abi=48 npm rebuild npm rebuild pocketsphinx npm rebuild pocketsphinx --abi=54 npm rebuild pocketsphinx --abi=48 node-gyp rebuild

All without success.

nshmyrev commented 6 years ago

Known issue if you want to use electron, see here:

https://stackoverflow.com/questions/39547292/node-module-version-mismatch-expected-50

You need to cleanup the environment you have from the old node version and try to understand what is going on instead of blindly trying everything.