evancohen / sonus

:speech_balloon: /so.nus/ STT (speech to text) for Node with offline hotword detection
MIT License
619 stars 79 forks source link

Keep getting "Unexpected token" issue on run #44

Closed pmagnussen closed 7 years ago

pmagnussen commented 7 years ago

Hi. Hoping you guys could help me with this one.

Whenever I run "npm run sonus" I get this error:

pi@raspberrypi:~/smart-mirror $ npm run sonus

> smart-mirror@0.0.13 sonus /home/pi/smart-mirror
> node sonus.js

/home/pi/smart-mirror/node_modules/sonus/index.js:5
const {Detector, Models} = require('snowboy')
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/pi/smart-mirror/sonus.js:20:15)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! smart-mirror@0.0.13 sonus: `node sonus.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the smart-mirror@0.0.13 sonus script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2017-05-29T20_11_45_582Z-debug.log

I'm running npm version 4.6.1 and Nodejs version 6.10.4. All on a Raspberry Pi 3.

Does anyone know what it could be?

pmagnussen commented 7 years ago

I tried changing the code to const Detector = require('snowboy') const Models = require('snowboy') But now I get this error:

/home/pi/smart-mirror/node_modules/sonus/index.js:63
    models = new Models(),
             ^

TypeError: Models is not a function
    at Object.CloudSpeechRecognizer.init.CloudSpeechRecognizer.startStreaming.recognitionStream.on.Sonus.init.opts.hotwords.forEach.detector.on.csr.on.csr.on.sonus.trigger [as init] (/home/pi/smart-mirror/node_modules/sonus/index.js:63:14)
    at Object.<anonymous> (/home/pi/smart-mirror/sonus.js:46:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:134:18)
    at node.js:962:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! smart-mirror@0.0.13 sonus: `node sonus.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the smart-mirror@0.0.13 sonus script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2017-05-29T20_35_41_651Z-debug.log
evancohen commented 7 years ago

Strange. This syntax should be supported by the version of node you have installed... Give this a shot instead:

const Detector = require('snowboy').Detector
const Models = require('snowboy').Models
pmagnussen commented 7 years ago

Yeah, I ended up doing something like that. Thanks.