Hello.
I've been using Repeaker 4-Mic Array, running SnowBoy (a keyword/hotword speech detection program) to detect keywords and direction it was spoken from.
I followed this website tutorial and the mic is able to detect direction of my voice (Direction of Arrival) calling out the keyword (which is "snowboy").
https://github.com/SeeedDocument/ReSpeaker-4-Mic-Array-for-Raspberry-Pi/blob/master/ReSpeaker-4-Mic-Array-for-Raspberry-Pi.md
I wanted to change the "snowboy" keyword to something else.
I took a look at SnowBoy documentation, and it says I need to change the keyword model to a newly-trained model
Snowboy, a Customizable Hotword Detection Engine — Snowboy 1.0.0..
The model file will be named with something like saved_model.pmdl
But, I don't know the location of the old keyword model I'm supposed to replace
I can't even find that Snowboy folder in my Raspberry pi SD card.
Anybody have any idea?
Thanks in advance.
All based of theory and no demonstration
According to documentation (http://docs.kitt.ai/snowboy/)
A snowboy hotword detector object is instantiated like this
detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
With model being defined a few lines up from an argv, so file-extensions aren't really important
What you do need though, is to make training data based on your new hotword, and you can either do this yourself, or use their service to make this file for you (There's a big green notice about this on the page linked above)
There's a couple of scripts to help with that https://github.com/Kitt-AI/snowboy/tree/master/examples/REST_API
So, now with your training data completed, looking for how the model is used.
the script from the ReSpeaker points to KWS using snowboy
script referring to ns_kws_doa_alexa.py from step 2 of Getting Started
kws = KWS(model='snowboy')
Jumping to the voice_engine/kws_snowboy.py
resource_path = os.path.join(os.path.dirname(snowboydetect.__file__), 'resources')
common_resource = os.path.join(resource_path, 'common.res')
if model in ['alexa', 'snowboy']:
model = os.path.join(resource_path, '{}.umdl'.format(model))
self.detector = snowboydetect.SnowboyDetect(common_resource, model)
Which, snowboydetect.__file__ can be found by typing the following into your console
from snowboy import snowboydetect
snowboydetect.__file__
Pretty easy, it should point to the PIP directory
Add your training model to the path, and name it <name>.umdl
As well as add your hotword to the array in the kws_snowboy.py file, which is in the example above, AND change the hotword used in your main() function from
kws = KWS(model='snowboy')
to like
kws = KWS(model='<file name to extension>')
From there, this will tell KWS to tell Snowboy to use a different model file
Thanks a lot. I wish I could give more coins. I amost gave up on the RePeaker, but now my robot will know will know where I'm calling him from. Will ask again if new things comes up.
Hello. I found the .umdl hotword file path, they are in
/home/pi/env/local/lib/python2.7/site-packages/snowboy/resources
i saw the model inside the directory are all have the extension .umdl (snowboy.umdl, alexa.umdl), but my newly-made model (from Snowboy website) have .pmdl extension (cibo.pmdl)
I tried changing the line in ns_kws_doa_alexa.py file to
kws = KWS(model='cibo')
but it doesnt work. The code just aborted
ERROR (Input():snowboy-io.cc:315) Fail to open input file "cibo"
terminate called after throwing an instance of 'std::runtime_error'
what(): ERROR (Input():snowboy-io.cc:315) Fail to open input file "cibo"
It does work if I specify the kws model as snowboy or alexa. But not the new model, cibo
I also tried to add the model name in kws_snowboy.py file
if model in ['alexa', 'snowboy', 'cibo']:
model = os.path.join(resource_path, '{}.umdl'.format(model))
self.detector = snowboydetect.SnowboyDetect(common_resource, model)
self.detector.SetSensitivity(str(sensitivity).encode())
But nothing changed.
Probably I didn't do this right.
Any idea on how to use this new model successfully?
Looks like the path to the cibo file is incorrect
Backed up by this issue, which uses the same error message as you see
https://github.com/Kitt-AI/snowboy/issues/162
Tried changing the .pmdl to .umdl, but same error as when it's unchanged:
ERROR (Input():snowboy-io.cc:315) Fail to open input file "cibo"
terminate called after throwing an instance of 'std::runtime_error'
what(): ERROR (Input():snowboy-io.cc:315) Fail to open input file "cibo"
[stack trace: ]
/home/pi/env/local/lib/python2.7/site-packages/snowboy/_snowboydetect.so(_ZN7snowboy13GetStackTraceEv+0x34) [0x755b1fa8]
/home/pi/env/local/lib/python2.7/site-packages/snowboy/_snowboydetect.so(_ZN7snowboy13SnowboyLogMsgD1Ev+0x4b8) [0x755b25e8]
/home/pi/env/local/lib/python2.7/site-packages/snowboy/_snowboydetect.so(_ZN7snowboy5InputC1ERKSs+0x264) [0x755b76d0]
/home/pi/env/local/lib/python2.7/site-packages/snowboy/_snowboydetect.so(_ZN7snowboy14PipelineDetect14ClassifyModelsERKSsPSsS3_+0x1ec) [0x755a74e8]
/home/pi/env/local/lib/python2.7/site-packages/snowboy/_snowboydetect.so(_ZN7snowboy14PipelineDetect8SetModelERKSs+0x158) [0x755a79f8]
/home/pi/env/local/lib/python2.7/site-packages/snowboy/_snowboydetect.so(_ZN7snowboy13SnowboyDetectC1ERKSsS2_+0x88) [0x755918b0]
/home/pi/env/local/lib/python2.7/site-packages/snowboy/_snowboydetect.so(+0x1e5b0) [0x7558f5b0]
Aborted
EDITED:
Okay, looks like its solved!
in the kws_doa.py file, instead of using on the
kws = KWS(model='<file name to extension>')
I used the full file name + extension, which is cibo.pmdl
kws = KWS(model='cibo.pmdl')
Then it detected the keyword without issues.
Which is strange because I can use 'snowboy' and 'alexa' name without their extension (.umdl)
I will tinker further to see whatnots
Appreciate your help tremendously!
I'll be sure to ask more if more issues came up. Sorry for the trouble
Sorry, you need to Log In to post a reply to this thread.