# Elevenlabs Tts

> ElevenLabs Text-to-Speech API for high-quality speech synthesis. Use when this capability is needed.

- Skill: `tomevault-io/elevenlabs-tts-2` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/elevenlabs-tts-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/elevenlabs-tts-2/raw
- Safety review: pending (external: skill-scanner WARNING, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/elevenlabs-tts-2

---


# ElevenLabs Text-to-Speech

Generate high-quality speech audio from text using the ElevenLabs API.

## Authentication

The API key is available as environment variable:
```bash
ELEVENLABS_API_KEY
```

Include in request header:
```
xi-api-key: $ELEVENLABS_API_KEY
```

## API Endpoints

### Text-to-Speech
```
POST https://api.elevenlabs.io/v1/text-to-speech/{voice_id}
```

**Request Body:**
```json
{
  "text": "Your text here",
  "model_id": "eleven_turbo_v2_5",
  "voice_settings": {
    "stability": 0.5,
    "similarity_boost": 0.5
  }
}
```

**Response:** Audio bytes (mp3 format by default)

## Popular Voice IDs

- `21m00Tcm4TlvDq8ikWAM` - Rachel (female, calm)
- `EXAVITQu4vr4xnSDxMaL` - Bella (female, soft)
- `ErXwobaYiN019PkySvjV` - Antoni (male, warm)
- `TxGEqnHWrfWFTfGW9XjX` - Josh (male, deep)

## Python Example

```python
import os
import requests

ELEVENLABS_API_KEY = os.environ.get("ELEVENLABS_API_KEY")
VOICE_ID = "21m00Tcm4TlvDq8ikWAM"  # Rachel

def text_to_speech(text, output_path):
    url = f"https://api.elevenlabs.io/v1/text-to-speech/{VOICE_ID}"

    headers = {
        "xi-api-key": ELEVENLABS_API_KEY,
        "Content-Type": "application/json"
    }

    data = {
        "text": text,
        "model_id": "eleven_turbo_v2_5",
        "voice_settings": {
            "stability": 0.5,
            "similarity_boost": 0.75
        }
    }

    response = requests.post(url, json=data, headers=headers)

    if response.status_code == 200:
        with open(output_path, "wb") as f:
            f.write(response.content)
        return True
    else:
        print(f"Error: {response.status_code} - {response.text}")
        return False
```

## Handling Long Text

ElevenLabs has a ~5000 character limit per request. For long documents:

1. Split text into chunks at sentence boundaries
2. Generate audio for each chunk
3. Concatenate using ffmpeg or pydub:

```bash
# Create file list
echo "file 'chunk1.mp3'" > files.txt
echo "file 'chunk2.mp3'" >> files.txt

# Concatenate
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp3
```

## Best Practices

- Split at sentence boundaries to avoid cutting words
- Check rate limits (varies by subscription tier)
- Cache generated audio to avoid redundant API calls

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/benchflow-ai) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

