Text To Speech

द्वारा ElevenLabs

ElevenLabs वॉइस AI का उपयोग करके टेक्स्ट को स्पीच में बदलें। टेक्स्ट से ऑडियो जनरेट करने, वॉइसओवर बनाने, वॉइस ऐप बनाने या 70+ भाषाओं में स्पीच सिंथेसाइज़ करने पर उपयोग करें।

npx skills add https://github.com/elevenlabs/skills --skill text-to-speech

ElevenLabs Text-to-Speech

Generate natural speech from text - supports 70+ languages, multiple models for quality vs latency tradeoffs.

Setup: See 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_multilingual_v2"
)

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";

const client = new ElevenLabsClient();
const audio = await client.textToSpeech.convert("JBFqnCBsd6RMkjVDRZzb", {
  text: "Hello, welcome to ElevenLabs!",
  modelId: "eleven_multilingual_v2",
});
audio.pipe(createWriteStream("output.mp3"));

cURL

curl -X POST "https://api.elevenlabs.io/v1/text-to-speech/JBFqnCBsd6RMkjVDRZzb" \
  -H "xi-api-key: $ELEVENLABS_API_KEY" -H "Content-Type: application/json" \
  -d '{"text": "Hello!", "model_id": "eleven_multilingual_v2"}' --output output.mp3

Models

Model IDLanguagesLatencyBest For
eleven_v370+StandardHighest quality, emotional range
eleven_multilingual_v229StandardHigh quality, long-form content
eleven_flash_v2_532~75msUltra-low latency, real-time
eleven_flash_v2English~75msEnglish-only, fastest
eleven_turbo_v2_532~250-300msBalanced quality/speed
eleven_turbo_v2English~250-300msEnglish-only, balanced

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 (only works with v2+ models).
  • 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",
    voice_settings=VoiceSettings(
        stability=0.5,
        similarity_boost=0.75,
        style=0.5,
        speed=1.0,             # 0.25 to 4.0 (default 1.0)
        use_speaker_boost=True
    )
)

Language Enforcement

Force specific language for pronunciation:

audio = client.text_to_speech.convert(
    text="Bonjour, comment allez-vous?",
    voice_id="JBFqnCBsd6RMkjVDRZzb",
    model_id="eleven_multilingual_v2",
    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",
    apply_text_normalization="on"
)

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",
    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",
    previous_text="This is the first part."
)

Output Formats

FormatDescription
mp3_44100_128MP3 44.1kHz 128kbps (default) - compressed, good for web/apps
mp3_44100_192MP3 44.1kHz 192kbps (Creator+) - higher quality compressed
mp3_44100_64MP3 44.1kHz 64kbps - lower quality, smaller files
mp3_22050_32MP3 22.05kHz 32kbps - smallest MP3 files
pcm_16000Raw PCM 16kHz - use for real-time processing
pcm_22050Raw PCM 22.05kHz
pcm_24000Raw PCM 24kHz - good balance for streaming
pcm_44100Raw PCM 44.1kHz (Pro+) - CD quality
pcm_48000Raw PCM 48kHz (Pro+) - highest quality
ulaw_8000μ-law 8kHz - standard for phone systems (Twilio, telephony)
alaw_8000A-law 8kHz - telephony (alternative to μ-law)
opus_48000_64Opus 48kHz 64kbps - efficient streaming codec
wav_44100WAV 44.1kHz - uncompressed with headers

Streaming

For real-time applications, use the stream method (returns 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_flash_v2_5"  # Ultra-low latency
)

for chunk in audio_stream:
    play_audio(chunk)

See references/streaming.md for WebSocket streaming.

Error Handling

try:
    audio = client.text_to_speech.convert(
        text="Generate speech",
        voice_id="invalid-voice-id"
    )
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_multilingual_v2"
)
audio = response.parse()
print(f"Characters used: {response.headers.get('x-character-count')}")

References

ElevenLabs की और Skills

Setup API Key
ElevenLabs
उपयोगकर्ताओं को ElevenLabs MCP टूल्स के साथ उपयोग के लिए ElevenLabs API कुंजी सेट करने की प्रक्रिया में मार्गदर्शन करता है। इसका उपयोग तब करें जब उपयोगकर्ता को ElevenLabs API कुंजी कॉन्फ़िगर करने की आवश्यकता हो, जब ElevenLabs टूल्स API कुंजी की कमी के कारण विफल हों, या जब उपयोगकर्ता ElevenLabs तक पहुँच की आवश्यकता का उल्लेख करे।
development
Agents
ElevenLabs
ElevenLabs के साथ वॉइस AI एजेंट बनाएं। वॉइस असिस्टेंट, ग्राहक सेवा बॉट, इंटरैक्टिव वॉइस कैरेक्टर या किसी भी रीयल-टाइम वॉइस संवाद अनुभव को बनाते समय उपयोग करें।
developmentofficial
Music
ElevenLabs
ElevenLabs Music API का उपयोग करके संगीत उत्पन्न करें। वाद्य ट्रैक, गीतों के साथ गाने, पृष्ठभूमि संगीत, जिंगल या किसी भी AI-जनित संगीत रचना बनाते समय उपयोग करें। प्रॉम्प्ट-आधारित जनरेशन, सूक्ष्म नियंत्रण के लिए रचना योजनाएँ, और मेटाडेटा के साथ विस्तृत आउटपुट का समर्थन करता है।
developmentofficial
Sound Effects
ElevenLabs
टेक्स्ट विवरण से इलेवनलैब्स का उपयोग करके ध्वनि प्रभाव उत्पन्न करें। ध्वनि प्रभाव बनाते समय, ऑडियो टेक्सचर उत्पन्न करते समय, एम्बिएंट ध्वनियाँ, सिनेमाई इम्पैक्ट, यूआई ध्वनियाँ, या कोई भी ऑडियो जो भाषण नहीं है, उत्पन्न करते समय उपयोग करें। लूपिंग, अवधि नियंत्रण और प्रॉम्प्ट प्रभाव ट्यूनिंग का समर्थन करता है।
developmentofficial
Speech To Text
ElevenLabs
ElevenLabs Scribe v2 का उपयोग करके ऑडियो को टेक्स्ट में लिखें। ऑडियो/वीडियो को टेक्स्ट में बदलने, उपशीर्षक बनाने, मीटिंग्स को लिखने या बोली गई सामग्री को प्रोसेस करने पर उपयोग करें।
developmentofficial