Voice Assistant Skill Timer
This summer I am making a personal voice assistant, because I like the idea of Alexa but I don't like volunteering to be spied on. Read the setup Post here. I've got the architecture set up with a server that runs a local model (usually one of the llamas but theoretically could be anything) and a satellite raspberry pi that does wakeword detection and query collection, and then the server processes the request. I have decided on a modular skills-based architecture to keep things clean and extendable.
The first skill is timers. Timers are very easy to write in Python. I just wrote a class that instantiates an object with a deadline, a tick interval of a half second, and a function that runs on every tick and checks if the current count is past the deadline. The interesting part was implementing the response, rather than waiting for the wake word. For that, I set up a simple websocket server that sends the timer up message to the satellite to read. Which is exactly why I chose this skill; it's really simple logic, but it lays the foundation for a wide variety of other skills later.
I also added a function to send the remaining time in a timer to the satellite, which is not useful for short timers but is good for longer ones, as well as the ability to cancel the timer.
One interesting note is that the model at first insisted on setting the timer in minutes no matter what I said. I had to add explicit instructions to the voice parsing model to not assume the user said minutes. Strange new paradigm of having to wrangle models.