evancohen / sonus

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

npm run sonus error UnhandledPromiseRejectionWarning after a while #22

Closed shoten closed 7 years ago

shoten commented 7 years ago

Description : Sonus is in the smart mirror project, in this project I have the error below after let's say 5 to 8 mn of running, the hotword detection works fine and I have no problem with the google speech api.

How to reproduce

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

smart-mirror@0.0.6 sonus /home/pi/smart-mirror-master node sonus.js (node:31118) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: stdout maxBuffer exceeded

Comments At first I thought it was an issue on the smart-mirror or in my config.js file, but then I ran "npm run sonus" just to test the audio capture, just wait around 5 to 8 mn and to do nothing and the error occured too.

Configuration For information, this is my configuration

pi@raspberrypi: ~/smart-mirror-master $ node -v v6.9.1 pi@raspberrypi: ~/smart-mirror-master $ npm -v 3.10.8

Ideas From what I have read around the web, it can be caused by two main things

  1. set the maxBuffer option when using child_process.exec stdout-buffer-issue-using-node-child-process

  2. a missing catch in a promise call promise-reject-possibly-unhandled-error

Do you have an idea ?

Laurent

sce9sc commented 7 years ago

this issue is with node-record-lpcm16 it uses execa

evancohen commented 7 years ago

Thanks for the detailed issue! I'll take a look at this over the weekend.

The Node.js Child Processes module (child_process) has two functions spawn and exec, the difference between the two is in what they return - spawn returns a stream and exec returns a buffer. As @sce9sc mentioned, node-record-lpcm16 uses execa (which in turn uses exec) and actually converts the buffer that it gets from execa into a stream.

I'm going to look into creating a custom implementation for this, because it looks like node-record-lpcm16 doesn't meet our needs.

Fijvect commented 7 years ago

Hey Evan! Any luck so far? I'm researching workarounds in the meantime... but am not having much luck :(

evancohen commented 7 years ago

This should be fixed with the most recent version of sonus 0.1.2 :)

Upgrade and reinstall dependencies and let me know if that works for you.

Fijvect commented 7 years ago

Just updated everything and it's working perfectly! Thank you so much!! :D