Skip to main content

AssemblyAI TTS

How to use AssemblyAI TTS with LiveKit Agents.

Overview

AssemblyAI text-to-speech is available in LiveKit Agents through LiveKit Inference and the AssemblyAI plugin. With LiveKit Inference, your agent runs on LiveKit's infrastructure to minimize latency. No separate provider API key is required, and usage and rate limits are managed through LiveKit Cloud. Use the plugin instead if you want to manage your own billing and rate limits. Pricing for LiveKit Inference is available on the pricing page .

LiveKit Inference

Use LiveKit Inference to access AssemblyAI TTS without a separate AssemblyAI API key.

Model nameModel IDLanguages
AssemblyAI TTS 1assemblyai/assemblyai-tts-1en, es, de, fr, it, pt

Usage

To use AssemblyAI, use the TTS class from the inference module:

from livekit.agents import AgentSession, inference
session = AgentSession(
tts=inference.TTS(
model="assemblyai/assemblyai-tts-1",
voice="49c443a4-8a1d-5f7e-b70b-98bdbd9823c3", # Audrey
language="en"
),
# ... llm, stt, vad, turn_handling, etc.
)
import { AgentSession, inference } from '@livekit/agents';
const session = new AgentSession({
tts: new inference.TTS({
model: "assemblyai/assemblyai-tts-1",
voice: "49c443a4-8a1d-5f7e-b70b-98bdbd9823c3", // Audrey
language: "en"
}),
// ... llm, stt, vad, turnHandling, etc.
});

Parameters

model
Required
string

The model ID from the models list.

voice
Required
string

The ID of the voice to use. See voices for guidance on selecting a voice.

languageLanguageCode

Language code for the input text. AssemblyAI doesn't detect the language of the text, so set this to match what your LLM produces.

extra_kwargsdict

Additional parameters to pass to the AssemblyAI TTS API. See model parameters for supported fields.

In Node.js this parameter is called modelOptions.

Model parameters

Pass the following parameters inside extra_kwargs (Python) or modelOptions (Node.js):

ParameterTypeDefaultNotes
word_timestampsboolTrueWhether to return per-word timings with the audio. LiveKit uses them for aligned transcripts.

Voices

LiveKit Inference supports the voices in the AssemblyAI voice library . To use a voice, copy its ID from the voice library into your agent session.

Each voice is recorded in one language. A voice can speak any supported language, but it keeps the accent of its recording, so pick a voice recorded in the language of your text and set language to match.

Custom voices

Custom AssemblyAI voices cloned in your own AssemblyAI account aren't available through LiveKit Inference. To use these, use the AssemblyAI plugin.

String descriptors

As a shortcut, you can also pass a descriptor with the model ID and voice directly to the tts argument in your AgentSession:

from livekit.agents import AgentSession
session = AgentSession(
tts="assemblyai/assemblyai-tts-1:49c443a4-8a1d-5f7e-b70b-98bdbd9823c3",
# ... llm, stt, vad, turn_handling, etc.
)
import { AgentSession } from '@livekit/agents';
const session = new AgentSession({
tts: "assemblyai/assemblyai-tts-1:49c443a4-8a1d-5f7e-b70b-98bdbd9823c3",
// ... llm, stt, vad, turnHandling, etc.
});

Plugin

LiveKit's plugin support for AssemblyAI lets you connect directly to AssemblyAI's Streaming TTS API with your own API key.

Available inPython
|
Node.js

Installation

Install the plugin:

uv add "livekit-agents[assemblyai]~=1.8"
pnpm add @livekit/agents-plugin-assemblyai@1.x

Authentication

The AssemblyAI plugin requires an AssemblyAI API key .

Set ASSEMBLYAI_API_KEY in your .env file.

Usage

Use AssemblyAI TTS within an AgentSession or as a standalone speech generator. For example, you can use this TTS in the Voice AI quickstart.

from livekit.plugins import assemblyai
session = AgentSession(
tts=assemblyai.TTS(
model="assemblyai-tts-1",
voice="49c443a4-8a1d-5f7e-b70b-98bdbd9823c3", # Audrey
),
# ... llm, stt, etc.
)
import * as assemblyai from '@livekit/agents-plugin-assemblyai';
const session = new voice.AgentSession({
tts: new assemblyai.TTS({
model: "assemblyai-tts-1",
voice: "49c443a4-8a1d-5f7e-b70b-98bdbd9823c3", // Audrey
}),
// ... llm, stt, etc.
});

The plugin keeps a pool of open websocket sessions and reuses them across replies. To open a session before the agent's first reply, call prewarm() on the TTS instance.

Parameters

This section describes some of the available parameters. See the plugin reference for a complete list of all available parameters.

modelstringDefault: "assemblyai-tts-1"

The model to synthesize with, by name or alias.

voicestringDefault: Audrey

The ID of the voice to use, from the AssemblyAI voice library  or a custom voice cloned in your AssemblyAI account. Voice slugs such as "aai-audrey" also work, but slugs can change and IDs don't.

A custom voice speaks only the language of its reference recording and is available only in the data zone where you created it.

languagestring

The language to synthesize, as a code (for example, "es" or "es-MX") or an English name (for example, "spanish"). Defaults to English for library voices, even one recorded in another language, so set this when you use a non-English voice. For a custom voice, defaults to the language of its reference recording.

sample_rateintDefault: 24000

Output sample rate in Hz. Valid values: 8000, 16000, 22050, 24000, 44100, 48000. The default is the service's native rate.

word_timestampsboolDefault: True

Whether to request per-word timings. LiveKit uses them for aligned transcripts.

base_urlstringDefault: "wss://tts.us.assemblyai.com"

The Streaming TTS host. Set to "wss://tts.eu.assemblyai.com" to keep text and audio in the EU data zone.

text_pacingbool | SentenceStreamPacerDefault: False

Paces sentence requests behind the audio already generated for the stream. Set to True to use the default pacer.

To change the voice, language, or model during a session, call update_options() (Python) or updateOptions() (Node.js). A reply that's already playing keeps its voice until it finishes.

Transcription timing

AssemblyAI TTS returns per-word timings by default, which LiveKit uses to sync the agent's transcript with its speech and to record how much of an interrupted reply the user heard. Set use_tts_aligned_transcript=True in your AgentSession configuration to use them. To learn more, see the docs.

Additional resources

The following resources provide more information about using AssemblyAI with LiveKit Agents.