Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:Elevenlabs Elevenlabs python Transcript Event Handling

From Leeroopedia
Knowledge Sources
Domains Speech_Recognition, Event_Driven_Architecture
Last Updated 2026-02-15 00:00 GMT

Overview

An event-driven architecture for processing real-time transcription results through registered callback handlers, supporting partial transcripts, committed transcripts, error events, and session lifecycle events.

Description

Transcript Event Handling provides the mechanism for applications to react to real-time transcription results. The system uses an observer pattern where callbacks are registered for specific event types, and the WebSocket message handler dispatches incoming messages to matching callbacks.

The event system defines multiple event types:

  • Session lifecycle: open, close, session_started
  • Transcription results: partial_transcript, committed_transcript, committed_transcript_with_timestamps
  • Error events: error, auth_error, quota_exceeded, rate_limited, transcriber_error, and more
  • Flow control: commit_throttled, queue_overflow, resource_exhausted

Specific error events also emit a generic ERROR event, allowing a single error handler to catch all error types.

Usage

Use this principle when consuming results from a realtime STT connection. Register handlers for the events you care about using connection.on(event, callback). At minimum, register handlers for COMMITTED_TRANSCRIPT and ERROR events.

Theoretical Basis

The event handling follows the Observer (publish-subscribe) pattern:

# Abstract event system
connection.on("partial_transcript", lambda data: update_live_caption(data))
connection.on("committed_transcript", lambda data: save_final_text(data))
connection.on("error", lambda data: log_error(data))

# Internal: WebSocket message loop dispatches to handlers
for message in websocket:
    event_type = message["message_type"]
    for handler in handlers[event_type]:
        handler(message)

Key design decisions:

  • Multiple handlers per event type (append-only registration)
  • Synchronous handler execution (handlers should be fast)
  • Specific error events also emit generic ERROR for unified error handling

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment