Text To Speech
ElevenLabsOfficialPublished by ElevenLabs
- Skill
- Tool integration
- Automation and integrations
- MIT
- Medium risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides an interface to the ElevenLabs text-to-speech API, enabling the conversion of text into spoken audio. It supports multiple models, voice selection, and various audio output formats. Developers can use the provided SDKs for Python and JavaScript or the CLI to generate audio files, stream audio in real-time, and apply voice settings or audio effects to customize the output.
What it does
- Converts text input into synthesized speech using ElevenLabs models.
- Supports streaming audio chunks for real-time applications.
- Allows selection of specific voice IDs and model configurations.
- Provides options for adjusting voice stability, similarity, and audio effects.
- Enables text normalization control for dates, numbers, and abbreviations.
- Supports request stitching for generating long-form audio across multiple calls.
When to use it
- When building voice-enabled applications or interactive agents.
- When you need to generate audio files from text programmatically.
- When integrating text-to-speech features into Python or JavaScript projects.
- When you require command-line access to speech synthesis services.
Advantages
- Supports over 90 languages depending on the selected model.
- Offers multiple output formats including MP3, PCM, and WAV.
- Provides granular control over voice characteristics and audio environment settings.
- Includes tools for monitoring API usage and character counts.
- Supports both file-based generation and real-time streaming.
Usage examples
- “Generate an audio file from the text 'Hello, welcome to ElevenLabs!' using the George voice.”
- The agent uses the ElevenLabs client to convert the provided text into an MP3 file using the specified voice ID.
- “Stream audio for the text 'This text will be streamed as audio.'”
- The agent initiates a stream from the ElevenLabs API and processes the audio chunks as they are received.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/elevenlabs/text-to-speech/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip text-to-speech.zip -d .agents/skills
Documentation by ElevenLabs
ElevenLabs Text-to-Speech
Generate natural speech from text - supports 90+ languages, multiple models for quality vs latency tradeoffs. Examples default to eleven_v4, the latest and highest-quality model.
Setup, before writing any code: if
ELEVENLABS_API_KEYisn't set for this project, runnpx -y @elevenlabs/cli@latest onboard initfrom the app's folder first and follow what it prints: it signs the user in and stores a key for the project, so nobody copies one by hand. Otherwise see the Installation Guide. For JavaScript, use@elevenlabs/*packages only.
Quick Start
Python
from elevenlabs import ElevenLabs
client = ElevenLabs()
audio = client.text_to_speech.convert(
text="Hello, welcome to ElevenLabs!",
voice_id="JBFqnCBsd6RMkjVDRZzb", # George
model_id="eleven_v4"
)
with open("output.mp3", "wb") as f:
for chunk in audio:
f.write(chunk)JavaScript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
import { createWriteStream } from "fs";
import { Readable } from "stream";
const client = new ElevenLabsClient();
const audio = await client.textToSpeech.convert("JBFqnCBsd6RMkjVDRZzb", {
text: "Hello, welcome to ElevenLabs!",
modelId: "eleven_v4",
});
// convert() returns a web ReadableStream — bridge it to a Node stream to write to disk
Readable.fromWeb(audio).pipe(createWriteStream("output.mp3"));CLI
Use say to play text immediately with the default voice and eleven_v3 model:
elevenlabs say "Hello!"Pipe text into say when another command produces the input:
echo "The build finished successfully." | elevenlabs sayUse the API command when you need to set request parameters directly:
elevenlabs text-to-speech convert --voice-id JBFqnCBsd6RMkjVDRZzb \
--text "Hello!" --model-id eleven_v4 --output output.mp3The CLI reads ELEVENLABS_API_KEY from the environment automatically.
Models
| Model ID | Languages | Latency | Best For |
|---|---|---|---|
eleven_v4 | 90+ | Standard | Default. Highest quality, emotional range, audio tags, voice cloning accuracy |
eleven_v4_turbo | 90+ | ~100ms | Real-time v4 quality for agents and interactive apps (via Text to Dialogue WebSocket) |
eleven_flash_v2_5 | 32 | ~75ms | Lowest latency, lowest cost, stream-input WebSocket |
eleven_flash_v2 | English | ~75ms | English-only, lowest latency |
eleven_multilingual_v2 | 29 | Standard | Previous generation; most stable on very long-form generations |
eleven_v3 | 70+ | Standard | Previous generation expressive model |
eleven_turbo_v2_5 and eleven_turbo_v2 are superseded by the Flash models (same output, lower latency) — use eleven_flash_v2_5 / eleven_flash_v2 instead.
Eleven v4 notes: supports only stability and similarity_boost voice settings (no style or speed), does not support SSML, and is not available on the stream-input TTS WebSocket. Direct delivery with audio tags such as [whispers], [laughs], [sarcastic].
Voice IDs
Use pre-made voices or create custom voices in the dashboard.
Popular voices:
JBFqnCBsd6RMkjVDRZzb- George (male, narrative)EXAVITQu4vr4xnSDxMaL- Sarah (female, soft)onwK4e9ZLuTAKqWW03F9- Daniel (male, authoritative)XB0fDUnXU5powFXDhCwa- Charlotte (female, conversational)
voices = client.voices.get_all()
for voice in voices.voices:
print(f"{voice.voice_id}: {voice.name}")Voice Settings
Fine-tune how the voice sounds:
Stability: How consistent the voice stays. Lower values = more emotional range and variation, but can sound unstable. Higher = steady, predictable delivery.
Similarity boost: How closely to match the original voice sample. Higher values sound more like the original but may amplify audio artifacts.
Style: Exaggerates the voice's unique style characteristics (v2/v3 models; not supported on Eleven v4).
Speed: Speech speed multiplier (v2/v3 models; not supported on Eleven v4).
Speaker boost: Post-processing that enhances clarity and voice similarity.
from elevenlabs import VoiceSettings
audio = client.text_to_speech.convert(
text="Customize my voice settings.",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_v4",
voice_settings=VoiceSettings(
stability=0.5, # Lower = more expressive, higher = more consistent
similarity_boost=0.75, # Higher = closer to the reference voice
)
)Language Selection
Use language_code with models that support language enforcement to guide pronunciation and text normalization. Unsupported language codes are ignored, and language_code is not supported on eleven_multilingual_v2.
audio = client.text_to_speech.convert(
text="Bonjour, comment allez-vous?",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_v4",
language_code="fr" # ISO 639-1 code
)Text Normalization
Controls how numbers, dates, and abbreviations are converted to spoken words. For example, "01/15/2026" becomes "January fifteenth, twenty twenty-six":
"auto"(default): Model decides based on context"on": Always normalize (use when you want natural speech)"off": Speak literally (use when you want "zero one slash one five...")
audio = client.text_to_speech.convert(
text="Call 1-800-555-0123 on 01/15/2026",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_v4",
apply_text_normalization="on"
)Audio Effects
Use audio_effects to process the generated audio with a filter preset, perceived distance, a reverb environment, a looped background noise bed, and stereo panning. Effects do not change the cost of a request.
| Field | Range | Description |
|---|---|---|
filter_preset_id | Catalog ID | Filter that colors the voice, such as phone or old_radio |
distance | 0-1 (default 0) | How far the speaker sounds from the microphone |
environment_id | Catalog ID | Reverb environment, such as small_room or hall |
send_level | 0-1 (default 1) | How much of the voice feeds the reverb; 0 turns reverb off |
background_noise_id | Catalog ID | Background noise looped under the voice, such as cafe or keyboard |
pan | -1 to 1 (default 0) | Stereo position of the voice, from hard left to hard right |
List valid filter preset, environment, and background noise IDs with the catalog endpoint (GET /v1/audio-effects/catalog):
from elevenlabs import EffectsSpecInput
catalog = client.audio_effects.get_catalog()
for environment in catalog.environments:
print(f"{environment.environment_id}: {environment.name}")
audio = client.text_to_speech.convert(
text="Welcome to the concert hall.",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_v4",
audio_effects=EffectsSpecInput(
environment_id="hall",
distance=0.3,
pan=-0.5,
)
)Reverb and non-zero pan produce stereo audio and are rejected for ulaw_*, alaw_*, and pcm_* output formats. Unknown effect IDs return a 404 error.
Request Stitching
When generating long audio in multiple requests, the audio can have pops, unnatural pauses, or tone shifts at the boundaries. Request stitching solves this by letting each request know what comes before/after it:
# First request
audio1 = client.text_to_speech.convert(
text="This is the first part.",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_v4",
next_text="And this continues the story."
)
# Second request using previous context
audio2 = client.text_to_speech.convert(
text="And this continues the story.",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_v4",
previous_text="This is the first part."
)Output Formats
| Format | Description |
|---|---|
mp3_44100_128 | MP3 44.1kHz 128kbps (default) - compressed, good for web/apps |
mp3_44100_192 | MP3 44.1kHz 192kbps (Creator+) - higher quality compressed |
mp3_44100_64 | MP3 44.1kHz 64kbps - lower quality, smaller files |
mp3_22050_32 | MP3 22.05kHz 32kbps - smallest MP3 files |
pcm_16000 | Raw PCM 16kHz - use for real-time processing |
pcm_22050 | Raw PCM 22.05kHz |
pcm_24000 | Raw PCM 24kHz - good balance for streaming |
pcm_44100 | Raw PCM 44.1kHz (Pro+) - CD quality |
pcm_48000 | Raw PCM 48kHz (Pro+) - highest quality |
ulaw_8000 | μ-law 8kHz - standard for phone systems (Twilio, telephony) |
alaw_8000 | A-law 8kHz - telephony (alternative to μ-law) |
opus_48000_64 | Opus 48kHz 64kbps - efficient streaming codec |
wav_44100 | WAV 44.1kHz - uncompressed with headers |
Streaming
Use the stream method to receive audio chunks as they're generated:
audio_stream = client.text_to_speech.stream(
text="This text will be streamed as audio.",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_v4"
)
for chunk in audio_stream:
play_audio(chunk)For real-time apps where latency matters most, use eleven_v4_turbo (~100ms) over the Text to Dialogue WebSocket, or eleven_flash_v2_5 (~75ms) over HTTP streaming or the stream-input WebSocket. See references/streaming.md.
Error Handling
try:
audio = client.text_to_speech.convert(
text="Generate speech",
voice_id="invalid-voice-id",
model_id="eleven_v4"
)
except Exception as e:
print(f"API error: {e}")Common errors:
401: Invalid API key
422: Invalid parameters (check voice_id, model_id)
429: Rate limit exceeded
Tracking Costs
Monitor character usage via response headers (x-character-count, request-id):
response = client.text_to_speech.convert.with_raw_response(
text="Hello!", voice_id="JBFqnCBsd6RMkjVDRZzb", model_id="eleven_v4"
)
audio = response.parse()
print(f"Characters used: {response.headers.get('x-character-count')}")References
Files
- ATTRIBUTION.mdAdded by AutoGineer812 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md10.5 KiB
- references/installation.md2.8 KiB
- references/streaming.md12.3 KiB
- references/voice-settings.md4.0 KiB
references/streaming.md
Streaming Audio
Stream audio chunks as they're generated for lower latency.
Model Selection for Streaming
| Model | Latency | Transport | Use Case |
|---|---|---|---|
eleven_v4 | Standard | HTTP streaming, Text to Dialogue WebSocket | Highest quality, 90+ languages |
eleven_v4_turbo | ~100ms | Text to Dialogue WebSocket | Real-time v4 quality for agents and interactive apps |
eleven_flash_v2_5 | ~75ms | HTTP streaming, stream-input WebSocket | Lowest latency, 32 languages |
eleven_flash_v2 | ~75ms | HTTP streaming, stream-input WebSocket | Lowest latency, English only |
eleven_turbo_v2_5 is superseded by eleven_flash_v2_5, which is functionally equivalent with lower latency.
Python Streaming
from elevenlabs import ElevenLabs
client = ElevenLabs()
audio_stream = client.text_to_speech.stream(
text="This is a streaming example.",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_v4"
)
with open("output.mp3", "wb") as f:
for chunk in audio_stream:
f.write(chunk)Real-Time Playback
import subprocess
def play_stream(audio_stream):
process = subprocess.Popen(
["ffplay", "-nodisp", "-autoexit", "-"],
stdin=subprocess.PIPE
)
for chunk in audio_stream:
process.stdin.write(chunk)
process.stdin.close()
process.wait()
audio_stream = client.text_to_speech.stream(
text="Playing this audio in real-time.",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_v4"
)
play_stream(audio_stream)JavaScript Streaming
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
import { createWriteStream } from "fs";
import { Readable } from "stream";
const client = new ElevenLabsClient();
const audioStream = await client.textToSpeech.convert("JBFqnCBsd6RMkjVDRZzb", {
text: "Streaming audio in JavaScript.",
modelId: "eleven_v4",
});
// Write to file (convert() returns a web ReadableStream — bridge to a Node stream first)
Readable.fromWeb(audioStream).pipe(createWriteStream("output.mp3"));
// Or process chunks
for await (const chunk of audioStream) {
console.log(`Received ${chunk.length} bytes`);
}Eleven v4 Turbo WebSocket
For real-time Eleven v4 quality (~100ms), stream text to eleven_v4_turbo over the Text to Dialogue WebSocket (/v1/text-to-dialogue/stream-input). This endpoint only accepts Eleven v3 and v4 models. eleven_v4_turbo allows exactly one registered voice per connection; eleven_v4 allows up to 10.
import asyncio
import base64
import json
import os
import websockets
from dotenv import load_dotenv
load_dotenv()
ELEVENLABS_API_KEY = os.getenv("ELEVENLABS_API_KEY")
VOICE_ID = "JBFqnCBsd6RMkjVDRZzb"
URI = (
"wss://api.elevenlabs.io/v1/text-to-dialogue/stream-input"
"?model_id=eleven_v4_turbo&output_format=mp3_44100_128"
)
async def stream_v4_turbo(text: str):
async with websockets.connect(URI) as websocket:
# First message registers voices and authenticates
await websocket.send(json.dumps({
"voices": [VOICE_ID],
"xi_api_key": ELEVENLABS_API_KEY,
}))
await websocket.send(json.dumps({
"inputs": [{"text": text, "voice_id": VOICE_ID, "new_turn": False}],
}))
# Flush remaining text and close after the final audio frame
await websocket.send(json.dumps({"close_socket": True}))
with open("output.mp3", "wb") as f:
while True:
msg = json.loads(await websocket.recv())
if msg.get("error"):
raise RuntimeError(msg)
if msg.get("audio"):
f.write(base64.b64decode(msg["audio"]))
if msg.get("is_final"):
break
asyncio.run(stream_v4_turbo(
"This is a longer line of dialogue so the server has enough text to start streaming audio. "
))import "dotenv/config";
import * as fs from "node:fs";
import WebSocket from "ws";
const voiceId = "JBFqnCBsd6RMkjVDRZzb";
const uri =
"wss://api.elevenlabs.io/v1/text-to-dialogue/stream-input?model_id=eleven_v4_turbo&output_format=mp3_44100_128";
const websocket = new WebSocket(uri);
const out = fs.createWriteStream("output.mp3");
websocket.on("open", () => {
websocket.send(JSON.stringify({ voices: [voiceId], xi_api_key: process.env.ELEVENLABS_API_KEY }));
websocket.send(JSON.stringify({
inputs: [{
text: "This is a longer line of dialogue so the server has enough text to start streaming audio. ",
voice_id: voiceId,
new_turn: false,
}],
}));
websocket.send(JSON.stringify({ close_socket: true }));
});
websocket.on("message", (data) => {
const msg = JSON.parse(data.toString());
if (msg.error) return console.error(msg);
if (msg.audio) out.write(Buffer.from(msg.audio, "base64"));
});
websocket.on("close", () => out.end());Behavior notes:
The server buffers about 40 characters and 8 words before emitting audio. Send
{"flush": true}to force generation of shorter text without closing.Omit
close_socketto keep the connection open between lines; send{"keep_alive": true}to reset the 20 second inactivity timeout.Set
new_turn: truewhen a speaker finishes a turn so prosody resets.Add
sync_alignment=trueto the query string to receivealignmenttiming data.Response fields are snake_case (
is_final). Each open connection holds one dialogue session from a pool separate from standard concurrency.
WebSocket Streaming
For text-streaming input where you send text chunks as they arrive (e.g., from an LLM) using Flash or Multilingual v2 models. The stream-input WebSocket does not support eleven_v3 or eleven_v4 — use the Eleven v4 Turbo WebSocket for those.
Connection
wss://api.elevenlabs.io/v1/text-to-speech/{voiceId}/stream-input?model_id={modelId}Note: This WebSocket does not support eleven_v3 or eleven_v4. Use eleven_flash_v2_5 here for lowest latency, or eleven_v4_turbo over the Text to Dialogue WebSocket.
Message Flow
Initialize - Send voice settings and configuration
Send text - Stream text chunks as they arrive
Close - Send empty string to signal completion
Receive - Process audio chunks as they're generated
Python WebSocket
import asyncio
import json
import base64
import os
import websockets
from dotenv import load_dotenv
load_dotenv()
ELEVENLABS_API_KEY = os.getenv("ELEVENLABS_API_KEY")
async def text_to_speech_ws_streaming(voice_id: str, model_id: str):
uri = f"wss://api.elevenlabs.io/v1/text-to-speech/{voice_id}/stream-input?model_id={model_id}"
async with websockets.connect(uri) as websocket:
# Initialize connection
await websocket.send(json.dumps({
"text": " ",
"voice_settings": {
"stability": 0.5,
"similarity_boost": 0.8
},
"generation_config": {
"chunk_length_schedule": [120, 160, 250, 290]
},
"xi_api_key": ELEVENLABS_API_KEY
}))
# Send text chunks
await websocket.send(json.dumps({"text": "Hello, "}))
await websocket.send(json.dumps({"text": "this is streaming text "}))
await websocket.send(json.dumps({"text": "from a WebSocket connection."}))
# Close stream (empty text signals completion)
await websocket.send(json.dumps({"text": ""}))
# Receive and process audio chunks
audio_chunks = []
while True:
message = await websocket.recv()
data = json.loads(message)
if data.get("audio"):
audio_chunks.append(base64.b64decode(data["audio"]))
elif data.get("isFinal"):
break
return b"".join(audio_chunks)
async def main():
audio = await text_to_speech_ws_streaming(
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_flash_v2_5"
)
with open("output.mp3", "wb") as f:
f.write(audio)
if __name__ == "__main__":
asyncio.run(main())JavaScript WebSocket
import "dotenv/config";
import WebSocket from "ws";
import * as fs from "node:fs";
const ELEVENLABS_API_KEY = process.env.ELEVENLABS_API_KEY;
async function textToSpeechWsStreaming(voiceId, modelId) {
const uri = `wss://api.elevenlabs.io/v1/text-to-speech/${voiceId}/stream-input?model_id=${modelId}`;
return new Promise((resolve, reject) => {
const websocket = new WebSocket(uri, {
headers: { "xi-api-key": ELEVENLABS_API_KEY },
});
const audioChunks = [];
websocket.on("open", () => {
// Initialize connection
websocket.send(
JSON.stringify({
text: " ",
voice_settings: {
stability: 0.5,
similarity_boost: 0.8,
},
generation_config: {
chunk_length_schedule: [120, 160, 250, 290],
},
})
);
// Send text chunks
websocket.send(JSON.stringify({ text: "Hello, " }));
websocket.send(JSON.stringify({ text: "this is streaming text " }));
websocket.send(JSON.stringify({ text: "from a WebSocket connection." }));
// Close stream
websocket.send(JSON.stringify({ text: "" }));
});
websocket.on("message", (event) => {
const data = JSON.parse(event.toString());
if (data.audio) {
audioChunks.push(Buffer.from(data.audio, "base64"));
} else if (data.isFinal) {
websocket.close();
resolve(Buffer.concat(audioChunks));
}
});
websocket.on("error", reject);
});
}
const audio = await textToSpeechWsStreaming(
"JBFqnCBsd6RMkjVDRZzb",
"eleven_flash_v2_5"
);
fs.writeFileSync("output.mp3", audio);Input Messages
Initialization (first message):
{
"text": " ",
"voice_settings": {
"stability": 0.5,
"similarity_boost": 0.8,
"use_speaker_boost": false
},
"generation_config": {
"chunk_length_schedule": [120, 160, 250, 290]
},
"xi_api_key": "your_api_key"
}Text chunks:
{ "text": "Your text content here" }Force flush (generate audio immediately):
{ "text": "End of sentence.", "flush": true }Close connection:
{ "text": "" }Output Messages
Audio chunk:
{
"audio": "base64_encoded_audio_data"
}Stream complete:
{
"isFinal": true
}Key Parameters
| Parameter | Description |
|---|---|
chunk_length_schedule | Array of character counts that trigger audio generation. The model waits until it has this many characters before generating audio, which improves quality but adds latency. Lower values = faster response, higher values = better prosody. Example: [120, 160, 250, 290] means generate after 120 chars, then after 160 more, etc. |
flush | Set true to force immediate audio generation without waiting for the character threshold. Use at the end of sentences or when you need audio NOW. |
voice_settings | Adjustable per-message: stability, similarity_boost, use_speaker_boost |
Important Notes
Inactivity timeout: Connection closes after 20 seconds without activity. Send a space
" "to keep alive.TTFB (Time to First Byte): How long until audio starts playing. Affected by
chunk_length_schedule- the model waits for enough text before generating.Model limitation: The
stream-inputWebSocket does not supporteleven_v3oreleven_v4; use the Text to Dialogue WebSocket for those.Best practice: Use
flush: trueat conversation turn endings to ensure the buffered text gets spoken.Alignment data: Word-level timestamps available via
alignmentfield for lip-sync or captions.
Best Practices
Pick a real-time model:
eleven_v4_turbofor the most expressive real-time speech (~100ms, Text to Dialogue WebSocket)eleven_flash_v2_5for the lowest latency and cost, multilingual (~75ms)eleven_flash_v2for English-only (~75ms)
Buffer audio before playback to prevent choppy output
Handle disconnections gracefully in WebSocket streams
Choose output format based on use case:
pcm_24000- lowest latency processingmp3_44100_128- direct playbackulaw_8000- telephony/Twilio integration
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an API key, Needs Python, Needs Node.js
The author says: Requires internet access and an ElevenLabs API key (ELEVENLABS_API_KEY).
Security
What our scanner noticed· Medium risk
- Instructions that use the network
- Downloads piped into a shell
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- ElevenLabs
- Publisher
- ElevenLabs (Official)
- Source
- elevenlabs/skills · text-to-speech · commit 9763c39
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by ElevenLabs or ElevenLabs.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download text-to-speech.zip