evancohen / sonus

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

example.js not working on macOS Sierra #66

Closed nezuky closed 6 years ago

nezuky commented 6 years ago

The code I am trying to run via Terminal:

node example.js


'use strict'

const ROOT_DIR = '/Users/Patrick/Documents/sonus/' const Sonus = require('sonus') const speech = require('@google-cloud/speech')({ projectId: 'voice-assistant-123919', keyFilename: ROOT_DIR + 'voice assistant-bf4caad39894.json' })

const hotwords = [{ file: ROOT_DIR + 'jarvis.pmdl', hotword: 'jarvis' }] const language = "en-US" const sonus = Sonus.init({ hotwords, language, recordProgram: "rec" }, 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('error', error => console.log('error', error)) sonus.on('final-result', result => { console.log("Final", result) if (result.includes("stop")) { Sonus.stop() } })

console.log(Done!);


**Output:**
>Say "jarvis"...
Done!

The code above is slighly modified from the original example.js, but is structurly the same.

There are no error messages which really confuses me, and the code just runs all the way through without even waiting to listen for hotwords.

(It acts as if something is quiting it)
evancohen commented 6 years ago

Usually this can be explained by an audio stream dieing. Did you install the recording dependencies?

brew install portaudio sox
nezuky commented 6 years ago

I have that installed.

Awhile ago I tried a different computer, and Sonus works! Still don't know what was wrong with the first laptop, but I guess I am fine.

Edit: Could be something to do with an antivirus I had installed, maybe it was killing the task.

evancohen commented 6 years ago

Since you have it working on another machine I'm going to close this issue - but I'm still curious about what was going on. If you ever get the chance to look into it more I'd be happy to help debug.