Principle:Elevenlabs Elevenlabs python Text Source Preparation
| Knowledge Sources | |
|---|---|
| Domains | Streaming, Data_Preparation |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
A user-defined pattern for creating a Python iterator that yields text fragments for consumption by the realtime text-to-speech streaming API.
Description
Text Source Preparation is the pattern of creating a Python generator or iterator that yields text strings for realtime TTS. This is not a library API but a user-implemented interface. The text source can be any generator: LLM streaming output, file reader, user keyboard input, or any other progressive text source.
The iterator must yield str values. The text_chunker utility will buffer these fragments at sentence boundaries before they are sent to the WebSocket API.
Usage
Implement this pattern whenever using convert_realtime. The text source is the text parameter.
Theoretical Basis
# Interface specification
def text_source() -> Iterator[str]:
"""Yield text fragments for realtime TTS."""
yield "fragment1"
yield "fragment2"
...