gptme-tts

Text-to-speech for [gptme](https://gptme.org): the agent's replies are read aloud as they stream in. Speech comes from a local TTS server (Kokoro, KittenTTS or Chatterbox) or from OpenRouter speech mo plugins/gptme-tts View on GitHub

gptme-tts

Text-to-speech for gptme: the agent's replies are read aloud as they stream in. Speech comes from a local TTS server (Kokoro, KittenTTS or Chatterbox) or from OpenRouter speech models.

Status: experimental. Needs a working audio output device.

Why use it

Hear what the agent says without watching the terminal, for example while it works through a long task. Speech starts sentence by sentence during streaming instead of waiting for the full reply, and code blocks, tool calls, markup and emoji are stripped before speaking.

For two-way, real-time conversations (microphone in, voice out, phone calls), see gptme-voice instead.

Install

Install into the same Python environment as gptme. The package registers itself through the gptme.plugins entry point:

pip install "git+https://github.com/gptme/gptme-contrib#subdirectory=plugins/gptme-tts"
# or, for a pipx-installed gptme:
pipx inject gptme "git+https://github.com/gptme/gptme-contrib#subdirectory=plugins/gptme-tts"

This adds a tts tool. The tool is only available when audio output works and a backend is reachable (see below). If you request it explicitly and it isn't available, gptme shows a hint about what is missing.

Quickstart (local server, Kokoro)

tts_server.py in this directory is a self-contained uv script; its dependencies are declared inline, so it needs no separate install.

# terminal 1: start the TTS server on 127.0.0.1:8765
cd /path/to/gptme-contrib/plugins/gptme-tts
./tts_server.py --backend kokoro

# terminal 2
gptme "hello, testing tts"

gptme checks for a server on localhost:8765 at startup and enables speech if it finds one.

Server options

Option Default Meaning
--backend kokoro kokoro, kittentts or chatterbox
--voice backend default Default voice (e.g. af_heart for Kokoro)
--lang a Kokoro language code (a = American English, b = British English, …)
--voice-dir — Directory of voice samples (Chatterbox)
--list-voices — List voices for the backend and exit
--list-backends — List backends whose dependencies are installed and exit
--host / --port 127.0.0.1 / 8765 Bind address. The gptme plugin always connects to localhost:8765, so keep the default port.
--cors-origin — Allowed browser origins, comma separated; also settable with TTS_CORS_ORIGIN.
-v, --verbose — Debug logging

Backend notes:

The server exposes GET /tts?text=…&voice=…&speed=… (returns WAV), /health, /voices and /backends.

Browser web UI

Allow the exact origin where you load the web UI (scheme, hostname and port), for example:

./tts_server.py --cors-origin 'https://chat.gptme.org,http://localhost:5701'
# equivalent:
TTS_CORS_ORIGIN='https://chat.gptme.org,http://localhost:5701' ./tts_server.py

No browser origins are allowed by default. --cors-origin '*' allows any origin. Browser local-network permissions still apply when accessing a local server from a hosted web UI.

OpenRouter backend (no local server)

export GPTME_TTS_BACKEND=openrouter
export OPENROUTER_API_KEY=...       # or set it in gptme's config
gptme "read me a haiku"

The default model is x-ai/grok-voice-tts-1.0 with voice Ara. Choose another with GPTME_TTS_MODEL and GPTME_TTS_VOICE.

Environment variables

Variable Meaning
GPTME_TTS_BACKEND server (default, local tts_server.py) or openrouter
GPTME_TTS_VOICE Voice name (depends on backend/model)
GPTME_TTS_SPEED Speed multiplier, 0.5–2.0 (default 1.0)
GPTME_TTS_TIMEOUT Per-request timeout in seconds (default 30)
GPTME_TTS_MODEL OpenRouter speech model when GPTME_TTS_BACKEND=openrouter
GPTME_VOICE_FINISH 1/true: wait for speech to finish before gptme exits

What the agent gets

Besides the automatic read-aloud hooks, the tts tool gives the agent these functions:

Automatic read-aloud and speak() are both active, so an explicit speak() is heard in addition to the normal reply.

Development

# from the gptme-contrib repo root
uv run pytest plugins/gptme-tts/tests