LiveKit
Overview
LiveKit Agents supports Speechify TTS in both of its frameworks, through plugins LiveKit publishes. You construct speechify.TTS(...) and pass it as the tts of your AgentSession, alongside your STT and LLM providers.
Both plugins stream. Each sentence of the agent’s reply is one request to POST /v1/audio/stream/with-timestamps, and the plugin forwards audio (24 kHz mono PCM) and word timestamps as they arrive. Requests share one keep-alive connection, and prewarm() opens it before the first reply; AgentSession calls prewarm() for you when the agent starts. Python 1.8.6 is the first release with connection reuse, prewarm() and a streamed synthesize(), so pin at least that version.
Prerequisites
- Speechify API key (platform.speechify.ai/api-keys)
- LiveKit project (URL, API key, and secret)
- Deepgram key for STT, OpenAI key for LLM (this guide’s stack; swap freely)
Install
Python
TypeScript
Configure
Put credentials in .env:
Both plugins read SPEECHIFY_API_KEY when you don’t pass a key to speechify.TTS(...) yourself (api_key= in Python, apiKey in Node.js). Keep it in the agent process, never in a browser participant.
Wire Speechify into AgentSession
Python
TypeScript
Save it as agent.py.
The speechify.TTS(...) line is the whole integration. Both plugins default to dominic_32 on simba-3.2. Pair voice_id (voiceId in Node.js) and model by language, not by voice family - the *_32 voices run on simba-3.5 and simba-3.0 too. simba-3.2 is English only, so pass it any English voice.
For another language, the Node.js plugin streams simba-3.5 in any of its 48 languages; for the best results, use a voice native to the language.
The Python plugin, as of 1.8.8, streams only simba-3.0 and simba-3.2 and synthesizes a simba-3.5 sentence whole before it plays, so in Python use simba-3.0 for German, Spanish, French, Italian or Brazilian Portuguese.
Each voice’s models list in GET /v1/voices is the authority. See Models for the compatibility matrix.
Verify without a LiveKit room
The plugin’s synthesize(...) method calls Speechify directly and streams the audio back, so you can prove the TTS path works before provisioning a room. Set SPEECHIFY_API_KEY in the environment first.
Python
TypeScript
A successful run writes speechify-tts-smoke.wav, about 4 seconds at 24 kHz mono.
Run the full agent
Once the smoke test passes, run against a LiveKit room:
Python
TypeScript
Troubleshooting
TLS certificate errors on macOS
If Python cannot verify TLS certificates when calling Speechify, point SSL_CERT_FILE at your system bundle or the certifi bundle before running:
SPEECHIFY_API_KEY not picked up
SPEECHIFY_API_KEY not picked up
The plugins only read the env var when you construct speechify.TTS() without a key. If you pass api_key= (Python) or apiKey (Node.js), it takes precedence; omit it to use the env var.
logger not initialized in a Node.js script
logger not initialized in a Node.js script
The agents CLI sets up logging for you. A standalone script that uses the plugin outside cli.runApp must call initializeLogger({ pretty: false, level: 'warn' }) from @livekit/agents first, as the smoke test above does.