Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Optimize ElevenLabs TTS latency and throughput through model selection, streaming strategies, audio format tuning, and caching. Latency ranges from ~75ms (Flash) to ~500ms (v3) depending on configuration.
The two highest-leverage, lowest-effort levers — model choice (Step 1) and output format (Step 2) — are documented inline below. The four deeper integrations (HTTP streaming, WebSocket streaming, caching, parallel generation) are summarized here with copy-ready code in the full implementation walkthrough.
The single biggest performance lever is model choice:
Model
Avg Latency
Quality
Languages
Use Case
eleven_flash_v2_5
~75ms
Good
32
Real-time chat, IVR, gaming
eleven_turbo_v2_5
~150ms
Good
32
Balanced speed/quality
eleven_multilingual_v2
~300ms
High
29
Narration, content creation
eleven_v3
~500ms
Highest
70+
Maximum expressiveness
// Select model based on use casefunctionselectModel(useCase: "realtime" | "balanced" | "quality" | "max_quality"): string {
const models = {
realtime: ,
: ,
: ,
: ,
};
models[useCase];
}
"eleven_flash_v2_5"
balanced
"eleven_turbo_v2_5"
quality
"eleven_multilingual_v2"
max_quality
"eleven_v3"
return
Step 2: Output Format Optimization
Smaller formats = faster transfer:
Format
Size/Second
Quality
Best For
mp3_44100_128
~16 KB/s
High
Downloads, archival
mp3_22050_32
~4 KB/s
Medium
Streaming, mobile
pcm_16000
~32 KB/s
Raw
Server-side processing
pcm_44100
~88 KB/s
Raw
High-quality processing
ulaw_8000
~8 KB/s
Phone
Telephony/IVR
// Use smaller format for streaming, higher quality for downloadsconst streamingConfig = {
output_format: "mp3_22050_32", // 4 KB/s — fast streamingmodel_id: "eleven_flash_v2_5", // ~75ms first byte
};
const downloadConfig = {
output_format: "mp3_44100_128", // 16 KB/s — high qualitymodel_id: "eleven_multilingual_v2",
};
Step 3: HTTP Streaming for Time-to-First-Byte
Call client.textToSpeech.stream() instead of .convert() and write each chunk to the response as it arrives, so playback starts before generation finishes — roughly halving time-to-first-byte. Set style: 0.0 in voice_settings to shave another 10–20%. Full server handler: implementation.md § Step 3.
Step 4: WebSocket Streaming for Lowest Latency
For interactive apps where text arrives incrementally (e.g., an LLM token stream), open a stream-input WebSocket, sendText() chunks as they arrive, and tune chunk_length_schedule — fewer characters per chunk means lower latency but less prosody context. Full bidirectional client: implementation.md § Step 4.
Step 5: Audio Caching
Cache generated audio for repeated content (greetings, prompts, errors) in an LRU cache keyed by a SHA-256 of voiceId:modelId:text, so a changed voice or model never serves stale audio. This eliminates ~99% of latency for repeated phrases. Full cachedTTS helper: implementation.md § Step 5.
Step 6: Parallel Generation
Generate multiple segments concurrently with a p-queue whose concurrency matches your plan's request limit (going higher returns 429s, not more throughput). Full chapter-generator: implementation.md § Step 6.
Output
Applying these levers produces:
A model + output-format choice matched to the use case (Steps 1–2).
A streaming code path (HTTP or WebSocket) that logs measured time-to-first-byte, e.g. Time to first byte: 78ms / WebSocket TTFB: 91ms.
An LRU audio cache emitting [Cache HIT] / [Cache MISS] telemetry for repeated content.
A concurrency-bounded batch path that logs per-segment generation time.
Expected latency after tuning: ~75–150ms first byte on Flash/Turbo with streaming, versus ~300–500ms for a blocking convert() call on a higher-quality model.
For cost optimization once latency is tuned, see the elevenlabs-cost-tuning skill, which covers character-usage budgeting, model-tier cost tradeoffs, and cache-hit-rate targets.