Skip to content

ElevenLabs speech integration for ADK

Supported in ADKPython v2.12.0Experimental

The ElevenLabsSTT and ElevenLabsTTS classes in Agent Development Kit (ADK) Python connect cascaded live voice agents to ElevenLabs speech models. In a cascaded live architecture, ElevenLabsSTT streams incoming client audio to ElevenLabs Scribe v2 Realtime for speech recognition and voice activity detection (VAD), while ElevenLabsTTS streams model text replies through ElevenLabs text-to-speech to generate streamed PCM audio.

Experimental

The ElevenLabs speech integration, including ElevenLabsSTT and ElevenLabsTTS, is an experimental feature. Its API may change in future releases. Do not use it in production.

To give an agent tool-based access to ElevenLabs features such as voice cloning, sound effects, or batch transcription, see the ElevenLabs Model Context Protocol (MCP) tool integration instead.

Use cases

  • Real-time voice agents with any text model: Pair ElevenLabs streaming speech recognition and synthesis with any ADK-supported text LLM, keeping your existing tools, instructions, and workflows unchanged.
  • Custom voice selection and multilingual speech: Pick voices from the ElevenLabs Voice Library and switch synthesis models to balance latency, quality, and language coverage.
  • Live captions and barge-in: Emit live partial transcripts while the user speaks and cancel in-flight synthesis immediately when the user interrupts the agent.
  • Pre-synthesis text guardrails: Wrap ElevenLabsTTS in a custom LiveEgress transform to inspect or redact streamed model text before audio synthesis begins.

Prerequisites

  • Python 3.11 or later with ADK Python v2.12.0 or later.
  • An ElevenLabs account and an ElevenLabs API key set in the ELEVENLABS_API_KEY environment variable.
  • Credentials for the text LLM that acts as the CascadeLive reasoner, such as a Gemini API key in GOOGLE_API_KEY or Google Cloud credentials. Because CascadeLive calls standard text generation on the reasoner, you do not need Gemini Live API access.

Installation

Install ADK Python with the elevenlabs extra, which installs a compatible elevenlabs SDK version >=2.22.1,<3:

pip install "google-adk[elevenlabs]"

Export your ElevenLabs API key before running your agent:

export ELEVENLABS_API_KEY="YOUR_ELEVENLABS_API_KEY"

Use with agent

Pass ElevenLabsSTT and ElevenLabsTTS into CascadeLive and assign it to your agent's model parameter. Run the agent with adk web and click the audio button in ADK Web, or drive it programmatically with Runner.run_live().

from google.adk.agents import Agent
from google.adk.integrations.eleven_labs import ElevenLabsSTT, ElevenLabsTTS
from google.adk.live import CascadeLive
from google.genai import types


def convert_temperature(value: float, from_unit: str) -> str:
    """Convert a temperature between Celsius and Fahrenheit."""
    unit = from_unit.strip().lower()
    if unit in ("c", "celsius"):
        converted = value * 9 / 5 + 32
        return f"{value:g} degrees Celsius is {converted:.1f} degrees Fahrenheit."
    if unit in ("f", "fahrenheit"):
        converted = (value - 32) * 5 / 9
        return f"{value:g} degrees Fahrenheit is {converted:.1f} degrees Celsius."
    return f"I can convert Celsius and Fahrenheit, but not {from_unit}."


root_agent = Agent(
    name="elevenlabs_voice_agent",
    model=CascadeLive(
        model="gemini-flash-latest",
        stt=ElevenLabsSTT(),
        tts=ElevenLabsTTS(),
    ),
    instruction=(
        "You are a helpful voice assistant. Keep answers to one or two short "
        "sentences and end every sentence with punctuation. Write numbers, "
        "symbols, and abbreviations as spoken words."
    ),
    tools=[convert_temperature],
    generate_content_config=types.GenerateContentConfig(
        thinking_config=types.ThinkingConfig(
            thinking_level=types.ThinkingLevel.LOW
        ),
    ),
)

For lower voice latency and cleaner synthesis, keep model thinking low in generate_content_config when using a model that supports thinking_level, and instruct the agent to end sentences with punctuation and spell out abbreviations. The same agent also works with Runner.run_async() for text-only requests, bypassing the speech transforms and calling the inner text model directly.

Customize voice, model, and VAD settings

Pass keyword arguments to ElevenLabsSTT and ElevenLabsTTS to change the voice, synthesis model, output sample rate, or server-side VAD sensitivity:

from google.adk.agents import Agent
from google.adk.integrations.eleven_labs import ElevenLabsSTT, ElevenLabsTTS
from google.adk.live import CascadeLive

stt = ElevenLabsSTT(
    model_id="scribe_v2_realtime",
    language_code="en",
    vad_silence_threshold_secs=1.0,
    vad_threshold=0.5,
)

tts = ElevenLabsTTS(
    voice_id="JBFqnCBsd6RMkjVDRZzb",  # Replace with any Voice ID from the ElevenLabs Voice Library
    model_id="eleven_flash_v2_5",
    sample_rate=24000,
)

root_agent = Agent(
    name="elevenlabs_voice_agent",
    model=CascadeLive(
        model="gemini-flash-latest",
        stt=stt,
        tts=tts,
    ),
    instruction=(
        "You are a helpful voice assistant. Keep answers to one or two short "
        "sentences and end every sentence with punctuation. Write numbers, "
        "symbols, and abbreviations as spoken words."
    ),
)

Available transforms

This integration exports two stream transform classes from google.adk.integrations.eleven_labs:

Class Base class Description
ElevenLabsSTT LiveIngress Streams 16-bit mono PCM audio (audio/pcm or audio/l16) to ElevenLabs Scribe v2 Realtime over WebSocket using server-side VAD. Emits UserSpeechStarted, PartialTranscript, and UserTurnFinished events.
ElevenLabsTTS LiveEgress Segments streamed LLM text into sentences and synthesizes raw 16-bit little-endian PCM audio via ElevenLabs streaming TTS. Emits AudioChunk and AgentSpokenOutput events, passes preceding sentence text for prosody continuity, and halts synthesis when canceled on barge-in.

Configuration

Environment variables

Variable Required Description
ELEVENLABS_API_KEY Yes, unless you pass api_key ElevenLabs API key used by ElevenLabsSTT and ElevenLabsTTS.

ElevenLabsSTT options

All parameters are keyword-only:

Option Type Default Description
model_id str "scribe_v2_realtime" ElevenLabs Scribe realtime model ID used for transcription.
language_code str \| None None Optional ISO-639-1 or ISO-639-3 language code hint.
vad_silence_threshold_secs float 0.8 Seconds of silence before server-side VAD commits and ends a user turn. Supported range: 0.3 to 3.0.
vad_threshold float 0.4 Voice activity detection threshold. Supported range: 0.1 to 0.9.
min_speech_duration_ms int 100 Minimum speech duration in milliseconds for VAD detection.
min_silence_duration_ms int 100 Minimum silence duration in milliseconds for VAD detection.
min_chunk_ms int 100 Minimum audio duration in milliseconds buffered before sending a chunk to ElevenLabs.
flush_timeout_secs float 3.0 Seconds to wait for a final committed transcript after closing the input audio stream.
api_key str \| None None Explicit ElevenLabs API key override. Defaults to ELEVENLABS_API_KEY.

Supported input PCM sample rates for ElevenLabsSTT are 8000, 16000, 22050, 24000, 44100, and 48000 Hz. When mime_type omits a rate parameter, ElevenLabsSTT defaults to 16000 Hz.

ElevenLabsTTS options

All parameters are keyword-only:

Option Type Default Description
voice_id str "JBFqnCBsd6RMkjVDRZzb" ElevenLabs voice ID for synthesis, defaulting to the "George" voice. Browse voices in the ElevenLabs Voice Library.
model_id str "eleven_flash_v2_5" ElevenLabs TTS model ID. See the ElevenLabs models overview for other supported synthesis models.
sample_rate int 24000 Output PCM sample rate in Hz, emitted with MIME type audio/pcm;rate=<sample_rate>. Supported values: 8000, 16000, 22050, 24000, 32000, 44100, and 48000.
max_sentence_chars int 240 Maximum characters buffered before forcing a split at the last word boundary, or at the limit when no space exists. Set to 0 or a negative value to disable length-based splitting.
api_key str \| None None Explicit ElevenLabs API key override. Defaults to ELEVENLABS_API_KEY.

Limitations

  • Silence-based turn detection: The ElevenLabsSTT adapter uses server-side VAD (CommitStrategy.VAD). A long mid-sentence pause can split an utterance into two turns, and continuous background noise can prevent a turn from committing. Tune vad_silence_threshold_secs, vad_threshold, min_speech_duration_ms, and min_silence_duration_ms to match your audio environment.
  • Regex-based sentence splitting: The ElevenLabsTTS adapter splits text on Latin punctuation ., !, ?, or … followed by optional quotes or brackets and whitespace; on CJK terminators 。, !, or ? followed by optional closing quotes or brackets once the next character arrives; on newlines; or at max_sentence_chars. Abbreviations such as Dr. Smith trigger an early split, and punctuation from scripts not covered by the regex falls back to the character limit.
  • Per-segment STT connections: Ending an audio segment closes the Scribe WebSocket session, and the next audio frame opens a new connection, adding connection setup latency when toggling the microphone repeatedly.
  • Cascaded live considerations: For general cascaded live limitations such as acoustic echo cancellation (AEC) and avoiding speech during synchronous tool calls, see Cascaded architecture.

Additional resources