{"name":"text-to-speech","url":"https://github.com/elevenlabs/skills/tree/main/text-to-speech","install":"npx skills add elevenlabs/skills --skill text-to-speech","sdk":"elevenlabs","key":"elevenlabs/text-to-speech","description":"Convert text to speech using ElevenLabs voice AI. Use when generating audio from text, creating voiceovers, building voice apps, or synthesizing speech in 70+ languages.","hasContent":true,"content":"---\nname: text-to-speech\ndescription: Convert text to speech using ElevenLabs voice AI. Use when generating audio from text, creating voiceovers, building voice apps, or synthesizing speech in 70+ languages.\nlicense: MIT\ncompatibility: Requires internet access and an ElevenLabs API key (ELEVENLABS_API_KEY).\nmetadata: {\"openclaw\": {\"requires\": {\"env\": [\"ELEVENLABS_API_KEY\"]}, \"primaryEnv\": \"ELEVENLABS_API_KEY\"}}\n---\n\n# ElevenLabs Text-to-Speech\n\nGenerate natural speech from text - supports 70+ languages, multiple models for quality vs latency tradeoffs.\n\n> **Setup:** See [Installation Guide](references/installation.md). For JavaScript, use `@elevenlabs/*` packages only.\n\n## Quick Start\n\n### Python\n\n```python\nfrom elevenlabs import ElevenLabs\n\nclient = ElevenLabs()\n\naudio = client.text_to_speech.convert(\n    text=\"Hello, welcome to ElevenLabs!\",\n    voice_id=\"JBFqnCBsd6RMkjVDRZzb\",  # George\n    model_id=\"eleven_multilingual_v2\"\n)\n\nwith open(\"output.mp3\", \"wb\") as f:\n    for chunk in audio:\n        f.write(chunk)\n```\n\n### JavaScript\n\n```javascript\nimport { ElevenLabsClient } from \"@elevenlabs/elevenlabs-js\";\nimport { createWriteStream } from \"fs\";\n\nconst client = new ElevenLabsClient();\nconst audio = await client.textToSpeech.convert(\"JBFqnCBsd6RMkjVDRZzb\", {\n  text: \"Hello, welcome to ElevenLabs!\",\n  modelId: \"eleven_multilingual_v2\",\n});\naudio.pipe(createWriteStream(\"output.mp3\"));\n```\n\n### cURL\n\n```bash\ncurl -X POST \"https://api.elevenlabs.io/v1/text-to-speech/JBFqnCBsd6RMkjVDRZzb\" \\\n  -H \"xi-api-key: $ELEVENLABS_API_KEY\" -H \"Content-Type: application/json\" \\\n  -d '{\"text\": \"Hello!\", \"model_id\": \"eleven_multilingual_v2\"}' --output output.mp3\n```\n\n## Models\n\n| Model ID | Languages | Latency | Best For |\n|----------|-----------|---------|----------|\n| `eleven_v3` | 70+ | Standard | Highest quality, emotional range |\n| `eleven_multilingual_v2` | 29 | Standard | High quality, long-form content |\n| `eleven_flash_v2_5` | 32 | ~75ms | Ultra-low latency, real-time |\n| `eleven_flash_v2` | English | ~75ms | English-only, fastest |\n| `eleven_turbo_v2_5` | 32 | ~250-300ms | Balanced quality/speed |\n| `eleven_turbo_v2` | English | ~250-300ms | English-only, balanced |\n\n## Voice IDs\n\nUse pre-made voices or create custom voices in the dashboard.\n\n**Popular voices:**\n- `JBFqnCBsd6RMkjVDRZzb` - George (male, narrative)\n- `EXAVITQu4vr4xnSDxMaL` - Sarah (female, soft)\n- `onwK4e9ZLuTAKqWW03F9` - Daniel (male, authoritative)\n- `XB0fDUnXU5powFXDhCwa` - Charlotte (female, conversational)\n\n```python\nvoices = client.voices.get_all()\nfor voice in voices.voices:\n    print(f\"{voice.voice_id}: {voice.name}\")\n```\n\n## Voice Settings\n\nFine-tune how the voice sounds:\n\n- **Stability**: How consistent the voice stays. Lower values = more emotional range and variation, but can sound unstable. Higher = steady, predictable delivery.\n- **Similarity boost**: How closely to match the original voice sample. Higher values sound more like the original but may amplify audio artifacts.\n- **Style**: Exaggerates the voice's unique style characteristics (only works with v2+ models).\n- **Speaker boost**: Post-processing that enhances clarity and voice similarity.\n\n```python\nfrom elevenlabs import VoiceSettings\n\naudio = client.text_to_speech.convert(\n    text=\"Customize my voice settings.\",\n    voice_id=\"JBFqnCBsd6RMkjVDRZzb\",\n    voice_settings=VoiceSettings(\n        stability=0.5,\n        similarity_boost=0.75,\n        style=0.5,\n        speed=1.0,             # 0.25 to 4.0 (default 1.0)\n        use_speaker_boost=True\n    )\n)\n```\n\n## Language Selection\n\nUse `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`.\n\n```python\naudio = client.text_to_speech.convert(\n    text=\"Bonjour, comment allez-vous?\",\n    voice_id=\"JBFqnCBsd6RMkjVDRZzb\",\n    model_id=\"eleven_v3\",\n    language_code=\"fr\"  # ISO 639-1 code\n)\n```\n\n## Text Normalization\n\nControls how numbers, dates, and abbreviations are converted to spoken words. For example, \"01/15/2026\" becomes \"January fifteenth, twenty twenty-six\":\n\n- `\"auto\"` (default): Model decides based on context\n- `\"on\"`: Always normalize (use when you want natural speech)\n- `\"off\"`: Speak literally (use when you want \"zero one slash one five...\")\n\n```python\naudio = client.text_to_speech.convert(\n    text=\"Call 1-800-555-0123 on 01/15/2026\",\n    voice_id=\"JBFqnCBsd6RMkjVDRZzb\",\n    apply_text_normalization=\"on\"\n)\n```\n\n## Request Stitching\n\nWhen 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:\n\n```python\n# First request\naudio1 = client.text_to_speech.convert(\n    text=\"This is the first part.\",\n    voice_id=\"JBFqnCBsd6RMkjVDRZzb\",\n    next_text=\"And this continues the story.\"\n)\n\n# Second request using previous context\naudio2 = client.text_to_speech.convert(\n    text=\"And this continues the story.\",\n    voice_id=\"JBFqnCBsd6RMkjVDRZzb\",\n    previous_text=\"This is the first part.\"\n)\n```\n\n## Output Formats\n\n| Format | Description |\n|--------|-------------|\n| `mp3_44100_128` | MP3 44.1kHz 128kbps (default) - compressed, good for web/apps |\n| `mp3_44100_192` | MP3 44.1kHz 192kbps (Creator+) - higher quality compressed |\n| `mp3_44100_64` | MP3 44.1kHz 64kbps - lower quality, smaller files |\n| `mp3_22050_32` | MP3 22.05kHz 32kbps - smallest MP3 files |\n| `pcm_16000` | Raw PCM 16kHz - use for real-time processing |\n| `pcm_22050` | Raw PCM 22.05kHz |\n| `pcm_24000` | Raw PCM 24kHz - good balance for streaming |\n| `pcm_44100` | Raw PCM 44.1kHz (Pro+) - CD quality |\n| `pcm_48000` | Raw PCM 48kHz (Pro+) - highest quality |\n| `ulaw_8000` | μ-law 8kHz - standard for phone systems (Twilio, telephony) |\n| `alaw_8000` | A-law 8kHz - telephony (alternative to μ-law) |\n| `opus_48000_64` | Opus 48kHz 64kbps - efficient streaming codec |\n| `wav_44100` | WAV 44.1kHz - uncompressed with headers |\n\n## Streaming\n\nFor real-time applications, use the `stream` method (returns audio chunks as they're generated):\n\n```python\naudio_stream = client.text_to_speech.stream(\n    text=\"This text will be streamed as audio.\",\n    voice_id=\"JBFqnCBsd6RMkjVDRZzb\",\n    model_id=\"eleven_flash_v2_5\"  # Ultra-low latency\n)\n\nfor chunk in audio_stream:\n    play_audio(chunk)\n```\n\nSee [references/streaming.md](references/streaming.md) for WebSocket streaming.\n\n## Error Handling\n\n```python\ntry:\n    audio = client.text_to_speech.convert(\n        text=\"Generate speech\",\n        voice_id=\"invalid-voice-id\"\n    )\nexcept Exception as e:\n    print(f\"API error: {e}\")\n```\n\nCommon errors:\n- **401**: Invalid API key\n- **422**: Invalid parameters (check voice_id, model_id)\n- **429**: Rate limit exceeded\n\n## Tracking Costs\n\nMonitor character usage via response headers (`x-character-count`, `request-id`):\n\n```python\nresponse = client.text_to_speech.convert.with_raw_response(\n    text=\"Hello!\", voice_id=\"JBFqnCBsd6RMkjVDRZzb\", model_id=\"eleven_multilingual_v2\"\n)\naudio = response.parse()\nprint(f\"Characters used: {response.headers.get('x-character-count')}\")\n```\n\n## References\n\n- [Installation Guide](references/installation.md)\n- [Streaming Audio](references/streaming.md)\n- [Voice Settings](references/voice-settings.md)\n","contentSource":"https://raw.githubusercontent.com/elevenlabs/skills/main/text-to-speech/SKILL.md","contentFetchedAt":"2026-07-28T23:15:41.388Z"}