Cerberus

This page last updated: 20 February 2025.

Note: the details of the initial part of this project, with whisper.cpp and Deep Seek, are described on Github, but then the focused moved to something called Home Assistant which is pretty well documented by the owners, so check there for details of the latter part.

I had been wondering if it were possible to make a voice-operated "home AI", basically something Alexa-like but without revealing my life to Amazon [at least, no more than I do when using a browser]; a brief look at whisper.cpp told me that was perfectly possible, so I bought an 8 gigabyte Pi 5, added a Codec Zero sound card and set to work.  This page is a brief record of how the home AI performed.

whisper.cpp Examples

whisper.cpp is a C implementation of a speech recognition model open-sourced by OpenAI, the makers of Chat GPT.  whisper.cpp also comes with a few really useful examples of how one might make a voice-commanded thing and how one might even connect that thing to a Large Language Model, for instance LLaMa, open sourced by Meta a few years ago, quantized and squished to run on the same Pi.

It took not much more than an afternoon, a day tops, of messing with the Pi to prove that all of this would work.  The whisper.cpp examples are so well put together, in fact, that I had more trouble making the Linux sound applications (aplay etc.) behave (ironically, requiring a little help from Deep Seek to get the command syntax correct) than I did with employing gigabytes of language model.  Here is a brief demo of the result, using a very squished LLaMa 3.2-1b running, along with the speech model, in less than 3 gigabytes of RAM on the Pi.
 
Now obviously this is not a useful thing in itself, such a squished LLM isn't likely to be useful, however the speech recognition is viable and timely, which is the key part.  I need to think next how to create a voice-prompted system that can carry out local commands and possibly, can do web searches and relay the result, maybe?  All to think about.

Deep Seek Version

A little while later whisper.cpp was updated to fix the bug that had prevented use of a higher quality Deep Seek-based model (occupying just over 7 gigabytes of RAM on the Pi 5) that was ARM optimised, which turned out to be quite responsive.  I also found that the whisper.cpp talk-llama example already included the ability to specify a key phrase (so that it would only respond when asked) and to emit an "I've heard you" phrase as a kind of work-around for the inevitable delay while the LLM "thinks".  Here is a video showing it working:
 
But still, the poor squished LLM was not sufficiently reliable: for Q&A-type stuff I would need to bounce off Deep Seek or the like for real.  Checking, it turns out that Home Assistant uses exactly the above for its voice interface (i.e.
whisper.cpp for input, Piper TTS for output) and might provide the integrations I would like.  Unfortunately Home Assistant only seems to work as an OS-type installation, so I will buy another SD card to try that out.

Home Assistant

Having spent a few days with Home Assistant (no Github updates for this, I am now just following the detailed instructions provided by Home Assistant) I have all of the devices on my home network connected to it, along with the cheapest voice control device it can use, trained to respond to "Hey Cerberus".  Native Home Assistant has fixed sentence patterns, so it is somewhat mechanical, but I can fix that in the next step.
 

Usable LLM, Graphics Card And Good Audio

A week later and I think I have done enough.  I had purchased one of the new 16 gigabyte Raspberry Pi 5's and tried running various Large Language Models on it.  This works fine if you ask simple questions, the model does not have much input data to parse, it just needs to consult its training data.  However, in the Home Assistant case it is being passed, effectively, the Home Assistant dashboard, along with your question/command concerning that data, each time, and that can be several kilobytes (configured as 8192 tokens to be exact); the poor Pi was taking 60 to 100 seconds to respond to this.

Then I remembered that I had a graphics card inside a Windows PC in the loft, installed there to drive my VR kit.  It is not a fancy graphics card, nearly 10 years old, an Nvidia GeForce GTX 1070 Ti with 8 gigabytes of RAM (half that of the Pi actually), but Ollama will cheerfully run under Windows so I installed it there and pointed the Home Assistant speech pipeline at it.  To be clear, all of the speech-to-text and text-to-speech (whisper.cpp, itself an LLM, and Piper TTS) continue to run on the Raspberry Pi 5 where Home Assistant is running (not shown in the video below), but now the LLM is running on this graphics card elsewhere on the same LAN.

I tried a few different LLMs under Ollama and settled on Llama 3.2-1B, the one that I had used on the Pi earlier: it seemed to have a good temperament, fitted in the RAM/processing space available on the graphics card and was able to use control APIs, something which relatively few LLMs had included in their training (e.g. the Deep Seek ones did not).

I also purchased the Voice Assistant Preview Edition hardware that the Home Assistant people make; while the sugar-cube sized M5 Atom microphone/speaker box had been excellent for £12, I wanted a much better speaker in particular. The hardware of the Voice Assistant Preview Edition, including two built-in microphones and a nice loud built-in speaker, turned out to very good; the software required a fair amount of fettling but hey, that is something I can do.

Here is a video record of the final result.  It is slow but there are ways I can speed it up yet. The key thing is that it does what I wanted, an utterly local AI (unless instructed to consult Google Gemini, the only on-line LLM that still has free API-based access) that is quite fun, you just have to know when it has made stuff up in order to please you.
 

Back to Meades Family Homepage