Voice Assistant
- Techniek
- Python · Ollama · ONNX Runtime · PySide6
- Team
- Solo
- Duur
- 3 weken (november 2026)
- Resultaat
- Draait volledig op mijn laptop
Aanleiding Spraakassistenten zoals die op je telefoon sturen alles wat je zegt naar de cloud, en ze kunnen weinig met je pc zelf. Ik wilde een assistent die ik met mijn stem bedien, die mijn Windows-laptop echt kan besturen en die helemaal lokaal draait: spraakherkenning, het taalmodel en de stem zitten allemaal op mijn eigen laptop. Alleen zoeken op internet en het weer gaan online.
- Tech
- Python · Ollama · ONNX Runtime · PySide6
- Team
- Solo
- Duration
- 3 weeks (November 2026)
- Result
- Runs entirely on my laptop
Background Voice assistants like the one on your phone send everything you say to the cloud, and they can't do much with your PC itself. I wanted an assistant I control with my voice, that can really operate my Windows laptop and that runs completely locally: speech recognition, the language model and the voice all live on my own laptop. Only web searches and the weather go online.
Wat het is Een Windows-programma dat op de achtergrond luistert naar een wake word. Daarna zeg je gewoon wat je wilt: een app openen, het volume zachter, muziek op Spotify, een timer, een herinnering, het weer, of een vraag. Het antwoord komt binnen ongeveer anderhalve seconde, uitgesproken door een Britse butlerstem, in het Engels, Nederlands of Braziliaans-Portugees. Een gloeiende bol van stippen rechtsonder laat zien wat de assistent doet: luisteren, denken of praten. Hij kan ook naar je scherm kijken, je stap voor stap door een programma leiden door een ring om de juiste knop te tekenen, en uitleg geven met kaarten die zichzelf op je scherm tekenen.
Hoe ik het gemaakt heb Ik ben begonnen met een plan in zeven fases, waarbij elke fase eindigde met iets wat ik echt kon gebruiken en testen. In fase 0 heb ik alles op mijn eigen laptop gemeten (een RTX 3060 met 6 GB videogeheugen) om de onderdelen te kiezen. Het grotere taalmodel van 8 miljard parameters paste niet in 6 GB en zakte naar zo'n 6 woorden per seconde, dus werd het het 4B-model: volledig op de GPU, eerste zin in 0,2 seconde. Daarna kwamen de spraaklus (fase 1), het besturen van de pc (2), geheugen en herinneringen (3), meekijken op je scherm (4), een instellingenpaneel en zelftest (5) en de extra's (6 en 7). Elk onderdeel heeft één taak: het wake word, het opnemen tot je stilvalt, spraak naar tekst, een router die simpele commando's direct uitvoert, het taalmodel met tools, en de stem.
Mijn rol Alles: het idee, het ontwerp van hoe de onderdelen samenwerken, het uitzoeken en meten van de modellen, de code en het testen. Ik heb het gebouwd in Python, met Ollama voor het taalmodel, ONNX Runtime voor de spraakmodellen en PySide6 (Qt) voor de bol, het paneel en alles wat op het scherm getekend wordt.
Praten terwijl hij nog nadenkt, en meteen stoppen als je hem onderbreekt
Als de assistent pas gaat praten wanneer het hele antwoord klaar is, wacht je seconden op stilte. Daarom knipt het programma het antwoord van het taalmodel in zinnen zodra die binnenkomen, en begint de stem met de eerste zin terwijl de rest nog geschreven wordt.
De spreker draait daarvoor op twee threads: één zet de volgende zin om in geluid terwijl de andere de huidige afspeelt, in blokjes van 50 ms. Om te onderbreken (“stop”, of Esc) hoog ik een generatienummer op. Alles in de wachtrij met een oud nummer wordt overgeslagen en het blokje dat speelt is het laatste, dus de stem stopt binnen ongeveer 50 ms, zonder dat ik threads hoef te stoppen of wachtrijen hoef te legen.
def stop(self) -> None:
"""Drops everything queued and stops the sentence that is playing."""
with self.lock:
self.generation += 1
self.pending = 0
self.idle.set()
self.onLevel(0.0)
def playLoop(self) -> None:
rate = self.voice.sampleRate
block = int(rate * BLOCK)
with sounddevice.OutputStream(samplerate=rate, channels=1, dtype="float32", blocksize=block) as stream:
while True:
generation, text, samples = self.sounds.get()
if not self.isCurrent(generation): continue
if text and not self.firstAudioAt: self.firstAudioAt = time.perf_counter()
if text: self.onSentence(text)
for start in range(0, len(samples), block):
if not self.isCurrent(generation): break
piece = samples[start:start + block]
self.onLevel(min(1.0, float(np.sqrt(np.mean(piece ** 2))) * 6))
padded = np.pad(piece, (0, block - len(piece)))
if self.echo: self.echo.addReference(padded, rate) # exactly what is played, so the mic can filter it out
stream.write(padded[:, None])
self.onLevel(0.0)
self.finishItem(generation)
Het volume van elk blokje gaat ook naar de bol, die daardoor meegolft met de stem.
What it is A Windows program that listens in the background for a wake word. After that you simply say what you want: open an app, turn the volume down, music on Spotify, a timer, a reminder, the weather, or a question. The answer comes within about one and a half seconds, spoken by a British butler voice, in English, Dutch or Brazilian Portuguese. A glowing sphere of dots in the corner shows what the assistant is doing: listening, thinking or talking. It can also look at your screen, guide you step by step through a program by drawing a ring around the right button, and explain things with cards that draw themselves on your screen.
How I made it I started with a plan in seven phases, where every phase ended with something I could actually use and test. In phase 0 I measured everything on my own laptop (an RTX 3060 with 6 GB of video memory) to pick the parts. The bigger 8-billion-parameter language model didn't fit in 6 GB and dropped to about 6 words per second, so it became the 4B model: fully on the GPU, first sentence in 0.2 seconds. Then came the voice loop (phase 1), controlling the PC (2), memory and reminders (3), looking at your screen (4), a settings panel and self-test (5) and the extras (6 and 7). Every part has one job: the wake word, recording until you stop talking, speech to text, a router that runs simple commands instantly, the language model with tools, and the voice.
My role Everything: the idea, the design of how the parts work together, researching and measuring the models, the code and the testing. I built it in Python, with Ollama for the language model, ONNX Runtime for the speech models and PySide6 (Qt) for the sphere, the panel and everything drawn on the screen.
Talking while it's still thinking, and stopping at once when you interrupt
If the assistant only starts talking once the whole answer is ready, you wait seconds in silence. So the program cuts the language model's answer into sentences as they come in, and the voice starts on the first sentence while the rest is still being written.
The speaker runs on two threads for this: one turns the next sentence into sound while the other plays the current one, in blocks of 50 ms. To interrupt (“stop”, or Esc) I raise a generation number. Everything in the queue with an old number is skipped and the block that is playing is the last one, so the voice stops within about 50 ms, without stopping threads or emptying queues.
def stop(self) -> None:
"""Drops everything queued and stops the sentence that is playing."""
with self.lock:
self.generation += 1
self.pending = 0
self.idle.set()
self.onLevel(0.0)
def playLoop(self) -> None:
rate = self.voice.sampleRate
block = int(rate * BLOCK)
with sounddevice.OutputStream(samplerate=rate, channels=1, dtype="float32", blocksize=block) as stream:
while True:
generation, text, samples = self.sounds.get()
if not self.isCurrent(generation): continue
if text and not self.firstAudioAt: self.firstAudioAt = time.perf_counter()
if text: self.onSentence(text)
for start in range(0, len(samples), block):
if not self.isCurrent(generation): break
piece = samples[start:start + block]
self.onLevel(min(1.0, float(np.sqrt(np.mean(piece ** 2))) * 6))
padded = np.pad(piece, (0, block - len(piece)))
if self.echo: self.echo.addReference(padded, rate) # exactly what is played, so the mic can filter it out
stream.write(padded[:, None])
self.onLevel(0.0)
self.finishItem(generation)
The loudness of every block also goes to the sphere, which ripples along with the voice.

