evancohen / sonus

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

Uncaught, unspecified "error" event. #24

Closed DeusRa closed 7 years ago

DeusRa commented 7 years ago

Hello again,

I´ve managed to make your example work. And it´s working for some time, but stops working after a while.

`**pi@raspberrypi:~/NodeJS/VIKI $ node sonus.js Say "alexa"... !alexa Partial es Partial test Final test !alexa Partial t Partial test Final test !alexa Partial Chef Partial test Final test !alexa events.js:146 throw err; ^

Error: Uncaught, unspecified "error" event. ([object Object]) at Writable.emit (events.js:144:17) at Writable. (/home/pi/NodeJS/node_modules/sonus/index.js:92:8) at emitOne (events.js:77:13) at Writable.emit (events.js:169:7) at null. (/home/pi/NodeJS/node_modules/sonus/index.js:37:62) at emitOne (events.js:82:20) at emit (events.js:169:7) at Duplexify._destroy (/home/pi/NodeJS/node_modules/@google-cloud/speech/node_modules/pumpify/node_modules/duplexify/index.js:184:15) at /home/pi/NodeJS/node_modules/@google-cloud/speech/node_modules/pumpify/node_modules/duplexify/index.js:175:10 at nextTickCallbackWith0Args (node.js:436:9)** ` My sonus.js looks like this:

`'use strict' var ini = require('node-ini'); var cfg = ini.parseSync('./config.ini');

const ROOT_DIR = '/home/pi/NodeJS/node_modules/sonus/' const Sonus = require(ROOT_DIR + 'index.js')

const speech = require('@google-cloud/speech')({ projectId: cfg.google.projectid, keyFilename: cfg.google.keyfile })

const hotwords = [{ file: './resources/alexa.umdl', hotword: 'alexa' }] const language = "de-DE" const sonus = Sonus.init({ hotwords, language }, speech)

Sonus.start(sonus) console.log('Say "' + hotwords[0].hotword + '"...')

sonus.on('hotword', (index, keyword) => console.log("!" + keyword))

sonus.on('partial-result', result => console.log("Partial", result))

sonus.on('final-result', result => { console.log("Final", result) if (result.includes("stop")) { Sonus.stop(); }

}) `

My system is Raspi2 (Model B). All npm versions on my system correspond to ones given in your package.json.

Greetings Nycon

DeusRa commented 7 years ago

Hello,

I got it working. Problem was: I had already a @google-cloud/speech npm installation on my system, but sonus is also coming with this node module; so there was a conflict. I uninstalled the @google-cloud/speech and just left the one with sonus. Additionally I added absolute path to requirements (require('/path/to/sonus/node_modules/@google-cloud/speech') and now it´s working beautifully. Thanks for this project. It rocks as hell.

Greeting Nycon