Voice output

Give it a voice

Add an offline text-to-speech boundary and keep it modular so you can upgrade voices later.

Chapter 08/10Time 15–30 minCost $0 software

Turn responses into audio

Text-to-speech is another replaceable module. The assistant only needs a function that accepts text and plays or returns audio.

Simple cross-platform starting point

The starter lists pyttsx3 as an optional dependency. It uses speech capabilities available on the local operating system.

python -m pip install -r requirements-voice.txt
import pyttsx3

engine = pyttsx3.init()
engine.say("Your offline assistant now has a voice.")
engine.runAndWait()

Keep TTS behind one function

def speak(text):
    engine.say(text)
    engine.runAndWait()

That one boundary makes it easy to switch later to a higher-quality local neural TTS engine without rewriting the controller.

Audio quality varies by platform

System voices and drivers differ. Treat this first implementation as a functional checkpoint. Upgrade the voice only after input, memory, and tool safety are stable.

Checkpoint

A model response is spoken through your speakers while the core LLM remains local.

Finished this chapter?
Your progress is stored only in this browser.