evancohen / sonus

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

Run on pi3 with minibian #40

Closed jaumard closed 7 years ago

jaumard commented 7 years ago

I'm trying to setup sonus on my pi 3 with minibian OS but doesn't work, I made a very small script who do:

const Sonus = require('sonus')
const speech = require('@google-cloud/speech')({
  projectId: 'projectID',
  keyFilename: './project-e522...efac7.json'
})

const hotwords = [{ file: './Hey_lisa.pmdl', hotword: 'hey lisa' }]
const language = 'fr-FR'
const sonus = Sonus.init({ hotwords, language }, speech)
Sonus.start(sonus)
sonus.on('hotword', (index, keyword) => console.log("!"))
sonus.on('final-result', console.log)

On my mac this script works perfectly but on my pi 3 the script start and after 2 seconds just finish without an error message :(

Any idea ? I install like the doc say sudo apt-get install sox libsox-fmt-all

jaumard commented 7 years ago

Also try this config for sonus as the doc say:

const sonus = Sonus.init({ hotwords, language, recordProgram: 'arecord'}, speech)
//or
const sonus = Sonus.init({ hotwords, language, recordProgram: 'arecord', device: 'plughw:1,0' }, speech)
//or 
const sonus = Sonus.init({ hotwords, language, recordProgram: 'arecord', device: 'hw:1,0' }, speech)

All same result, script end after few seconds without any error message :(

evancohen commented 7 years ago

It's possible that minibian isn't supported by snowboy. You might try running it standalone to see if the error is firing silently. What version of Node are you using?

You may need to re-build the module since it's compiled for a full version of raspbian (worst case you'll see what you're missing). Install build deps:

sudo apt-get install libatlas-base-dev

And then build the module from scratch when installing

npm install --fallback-to-build
jaumard commented 7 years ago

I use node v7.9.0 I just try npm install --fallback-to-build but no problem :( but same result

I also try snowboy directly by following this http://docs.kitt.ai/snowboy/ and first I have this error rec FAIL formats: can't open input default': snd_pcm_open error: No such file or directory but once I first do export AUDIODEV=hw:1,0 then rec temp.wav work correctly so I try again my little sample but same result it just start and finish after 1/2 seconds

jaumard commented 7 years ago

I tried to run the snowboy demo but I have those errors:

python demo.py Hey_lisa.pmdl 
Traceback (most recent call last):
  File "demo.py", line 1, in <module>
    import snowboydecoder
  File "/var/www/sonus/rpi-arm-raspbian-8.0-1.2.0/snowboydecoder.py", line 5, in <module>
    import snowboydetect
  File "/var/www/sonus/rpi-arm-raspbian-8.0-1.2.0/snowboydetect.py", line 21, in <module>
    _snowboydetect = swig_import_helper()
  File "/var/www/sonus/rpi-arm-raspbian-8.0-1.2.0/snowboydetect.py", line 20, in swig_import_helper
    return importlib.import_module('_snowboydetect')
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

Not familiar enough why python to know what it means and fix it...

jaumard commented 7 years ago

Ok it was just python-dev to install ^^ the demo is working great... but still not sonus :(

jaumard commented 7 years ago

Ok I made the hotword working by doing export LD_LIBRARY_PATH=/usr/local/lib/python2.7/ but now another error with google speech :(

export LD_LIBRARY_PATH=/usr/local/lib/python2.7/
node index.js 
!
{ streamingError: 
   Error: .google.cloud.speech.v1.RecognitionConfig#sampleRate is not a field: undefined
       at MessagePrototype.set (/var/www/sonus/node_modules/protobufjs/dist/protobuf.js:2490:35)
       at MessagePrototype.set (/var/www/sonus/node_modules/protobufjs/dist/protobuf.js:2483:38)
       at Message (/var/www/sonus/node_modules/protobufjs/dist/protobuf.js:2411:34)
       at Element.ProtoBuf.Reflect.ElementPrototype.verifyValue (/var/www/sonus/node_modules/protobufjs/dist/protobuf.js:1925:28)
       at Field.ProtoBuf.Reflect.FieldPrototype.verifyValue (/var/www/sonus/node_modules/protobufjs/dist/protobuf.js:3499:33)
       at MessagePrototype.set (/var/www/sonus/node_modules/protobufjs/dist/protobuf.js:2493:59)
       at MessagePrototype.set (/var/www/sonus/node_modules/protobufjs/dist/protobuf.js:2483:38)
       at Message (/var/www/sonus/node_modules/protobufjs/dist/protobuf.js:2411:34)
       at Element.ProtoBuf.Reflect.ElementPrototype.verifyValue (/var/www/sonus/node_modules/protobufjs/dist/protobuf.js:1925:28)
       at Field.ProtoBuf.Reflect.FieldPrototype.verifyValue (/var/www/sonus/node_modules/protobufjs/dist/protobuf.js:3499:33) }

Any idea ?

evancohen commented 7 years ago

This should be fixed in the latest commit in master. I'll be updating the npm package later today.