NOTE: As Snowboy isn't compatible with Microsoft Windows as of yet, I used a computer running MacOS Sierra.
Following the instructions on snowboy.kitt.ai, I proceeded to install prerequisites and download the tarball containing the code.
Among the prerequisites was Homebrew, a package manager similar to the apt module in Linux. I used it to install PortAudio, then used pip to install PyAudio, the Python bindings for PortAudio.
I then navigated to snowboy.kitt.ai, where I made my personal hotword detection model (a .pmdl file), and wired it into the demo.py by running it with the detection model as a argument.
Using this demo file, whenever the word 'Athena' was mentioned, it made a ding.
The code in the demo.py is as follows:
From what I gather, a signal handler is a function that, well, handles a signal. It's basically 'if I receive this signal, I handle it by executing this function'. The signal handler turns the bool value interrupted to True.
The interrupt callback function, when called, returns the bool value of interrupted. I presume that when the detector calls the interrupt callback function and the value becomes True, the detector exits.
signal.signal(signal.SIGINT, signal_handler) basically says to the program 'if this signal is present, execute the function signal_handler'.
Below that, a 'detector' object is created, with the personal model as an argument along with the sensitivity. When the detector is started, it requires 3 arguments:
Which function to trigger when the hotword is spoken (detected_callback),
Which function to trigger to check whether the detector has been interrupted (interrupt_callback),
Time between checking for interrupt (sleep_time).
The detector keeps running, and checks every 0.03s for an interrupt signal. The detector then stops.
Using the functions from the demo.py, I have all the information I need to make my voice assistant work. The rough flowchart is as follows:
A good approach to this is making the code modular, in different .py files. Using classes and objects, I can make the code much less complicated than if everything was in the same .py file.
Up next: coding my own Snowboy hotword detection, using snowboydecoder.py.