Kitt-AI / snowboy

Future versions with model training module will be maintained through a forked version here: https://github.com/seasalt-ai/snowboy
Other
3.07k stars 998 forks source link

Detection lag with Node module #87

Closed chenguoguo closed 7 years ago

chenguoguo commented 7 years ago

Email from hudreous@gmail.com:

It happens pretty early for me... usually after about 6 hotword detections, the lag between the spoken word and the detection becomes around 2 seconds. I have only tried it with Node so far, since the Python example doesn't seem to work on my Ubuntu 16.04 installations and I can't seem to make the C++ example successfully.

I didn't notice any CPU or RAM increases with node as the lag became an issue. Killing all node processes doesn't seem to help.

I was just able to fully test the Python example. It does not have this problem.

DeusRa commented 7 years ago

Hello, I've got a similar problem. I'm using Raspberry Pi 2 Model B with Node v4. 6.2 (arm7). But in my case RAM is increasing and snowboy stops detecting (actually freezing) everytime RaspPi reaches 137000 KB of RAM. When executed my node snowboy. js, ps aux shows it uses around 126M of memory and it increases quite fast depending on noises but it freezes everytime when 138M is reached. My free RAM is around 700M on my Rasbian Jessie. Did not check Python though.

Greetings Nycon

evancohen commented 7 years ago

@DeusRa you're likely experiencing something slightly different. Your issue is likely due to a recent change in the recording library that we're using: gillesdemey/node-record-lpcm16#15

I think we've found a viable solution, so hopefully this will be fixed shortly.

mevatron commented 7 years ago

@chenguoguo I'm also seeing a similar problem. I've upgraded node-record-lpcm16 to 0.1.8, but it definitely seems to slow down from ~1 second between detections to ~4 seconds between detections. I'm running Node.js with Ubuntu 14.04.

chenguoguo commented 7 years ago

thanks for reporting @mevatron . @evancohen is working on a fix, i'll give it a shot when i get time too

evancohen commented 7 years ago

I may have a fix for this now, but I'll need to do some more testing evancohen/sonus#27

evancohen commented 7 years ago

Ok. I think I finally figured out what is going on here, not by understanding what the issue is, but by finding what appears to be the solution: Don't use sox. Instead, use arecord.

https://github.com/evancohen/sonus/pull/30

With this change I've seen ~2-3x performance boost in detection using the node library on the Pi.

@telarium and @mevatron can you test the latest version of Sonus and use arecord?

cendev commented 7 years ago

I can confirm that using arecord solves this issue.