ElevenLabs Python SDK क्या है?
ElevenLabs Python SDK ElevenLabs voice API के लिए आधिकारिक Python client: स्पीच सिंथेसिस, streaming, voice cloning और voice agents. यह Multimodal Generation टूल्स की Media Model APIs श्रेणी में आता है; ओपन सोर्स है, Python में लिखा गया है और MIT लाइसेंस के तहत है। शुरू करने के लिए: sDK इंस्टॉल करें.
सारांश
ElevenLabs Python SDK ElevenLabs API के लिए आधिकारिक Python library है, जिसे `pip install elevenlabs` से इंस्टॉल किया जाता है। यह HTTP API को `ElevenLabs` client में लपेटता है, जिसके resources API reference को दर्शाते हैं: स्पीच सिंथेसिस के लिए `text_to_speech.convert` और `text_to_speech.stream`, voices खोजने और clone करने के लिए `voices.search` और `voices.ivc.create`, उपलब्ध models के लिए `models.list`, और भी बहुत कुछ। `AsyncElevenLabs` वही calls asyncio code के लिए देता है, और `play` और `stream` जैसे helpers audio सीधे आपके speakers तक भेजते हैं।
Library खुद MIT-licensed है, लेकिन यह एक hosted service का client है: हर request के लिए ElevenLabs API key चाहिए, जिसे ElevenLabs dashboard में बनाया जाता है और `api_key=` के रूप में या `ELEVENLABS_API_KEY` environment variable के जरिए पास किया जाता है। उपयोग का बिल आपके ElevenLabs plan पर बनता है। $0 वाला Free plan भी है और paid tiers भी, इसलिए SDK इंस्टॉल करना मुफ़्त है, लेकिन बड़े पैमाने पर चलाना मुफ़्त नहीं है।
एक बार की synthesis से आगे, SDK real-time voice काम भी कवर करता है। `conversational_ai` module स्थानीय audio interface के साथ ElevenAgents sessions चलाता है और आपको sync या async Python functions को client tools के रूप में रजिस्टर करने देता है, जिन्हें agent बातचीत के बीच में call कर सकता है। केवल-async Speech Engine एक WebSocket server खोलता है जिससे ElevenLabs कनेक्ट होता है: यह user transcripts प्राप्त करता है, आपको किसी भी LLM (OpenAI, Anthropic और Google Gemini streams अपने-आप पहचाने जाते हैं) से जवाब देने देता है, user बीच में टोके तो चल रहे जवाब को रद्द कर देता है, और जाँचता है कि हर आने वाला connection ElevenLabs द्वारा साइन किया गया है। यह library ElevenLabs की API definition से Fern के जरिए generate होती है, इसलिए code बदलाव सीधे pull requests के बजाय विक्रेता के generator से होकर जाते हैं।
यह क्या करता है
- Sync `ElevenLabs` और async `AsyncElevenLabs` clients, जो ElevenLabs HTTP API को कवर करते हैं, जिसमें text-to-speech, voices और models शामिल हैं
- Eleven v3, Multilingual v2, Flash v2.5 और Turbo v2.5 जैसे models के विकल्प के साथ text-to-speech, जिन्हें `model_id` के जरिए हर call पर चुना जा सकता है
- Real-time streaming: `text_to_speech.stream` audio bytes को उसी समय देता है जब वे generate होते हैं, जिन्हें आप स्थानीय रूप से चला सकते हैं या chunk-दर-chunk process कर सकते हैं
- `voices.ivc.create` से कुछ audio samples के आधार पर instant voice cloning, साथ में voice search और हर voice के लिए settings
- स्थानीय audio interface और client tools के रूप में रजिस्टर्ड Python functions के साथ ElevenAgents conversations, custom asyncio event loop support के साथ
- Server-side voice agents के लिए Speech Engine WebSocket server: कोई भी LLM लाएँ, अपने-आप interruption handling, और FastAPI/Starlette integration
शुरू करें
आपको Python और एक ElevenLabs account चाहिए जिसकी API key हो (Free plan उपलब्ध है; उससे अधिक उपयोग के लिए भुगतान करना होता है)। ये steps SDK README और ElevenLabs quickstart के अनुसार हैं।
SDK इंस्टॉल करें
PyPI से package इंस्टॉल करें। Quickstart .env फ़ाइल से API key लोड करने के लिए python-dotenv भी इंस्टॉल करता है।
pip install elevenlabs
pip install python-dotenvअपनी API key जोड़ें
ElevenLabs dashboard में (Settings → API keys) एक API key बनाएँ और उसे .env फ़ाइल में सहेजें। इसे गुप्त रखें — इसे कभी client-side code में न डालें।
ELEVENLABS_API_KEY=<your_api_key_here>टेक्स्ट को स्पीच में बदलें
एक client बनाएँ और voice ID व model ID के साथ text_to_speech.convert कॉल करें, फिर परिणाम चलाएँ। स्थानीय playback के लिए आपसे MPV और/या ffmpeg इंस्टॉल करने को कहा जा सकता है।
from dotenv import load_dotenv
from elevenlabs.client import ElevenLabs
from elevenlabs.play import play
load_dotenv()
elevenlabs = ElevenLabs()
audio = elevenlabs.text_to_speech.convert(
text="The first move is what sets everything in motion.",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_v3",
output_format="mp3_44100_128",
)
play(audio)जैसे-जैसे बने, audio stream करें
कम time-to-first-audio के लिए text_to_speech.stream का उपयोग करें और या तो stream चलाएँ या byte chunks खुद संभालें।
from elevenlabs import stream
from elevenlabs.client import ElevenLabs
elevenlabs = ElevenLabs(
api_key="YOUR_API_KEY",
)
audio_stream = elevenlabs.text_to_speech.stream(
text="This is a test",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_multilingual_v2"
)
# option 1: play the streamed audio locally
stream(audio_stream)
# option 2: process the audio bytes manually
for chunk in audio_stream:
if isinstance(chunk, bytes):
print(chunk)voices की सूची देखें या एक को clone करें
अपने account में उपलब्ध voices खोजें, या अपने audio samples से instant voice clone बनाएँ।
from elevenlabs.client import ElevenLabs
elevenlabs = ElevenLabs(
api_key="YOUR_API_KEY",
)
response = elevenlabs.voices.search()
print(response.voices)
voice = elevenlabs.voices.ivc.create(
name="Alex",
description="An old American male voice with a slight hoarseness in his throat. Perfect for news",
files=["./sample_0.mp3", "./sample_1.mp3", "./sample_2.mp3"],
)कमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।
कब इस्तेमाल करें
- किसी Python app, script या content pipeline में ElevenLabs narration या character voices जोड़ना
- chatbot, game या live assistant में कम latency के साथ synthesized speech stream करना
- Python में voice agent बनाना — या तो अपने client tools वाला ElevenAgents session, या Speech Engine server जो transcripts का जवाब आपके चुने LLM से देता है
- Backend code से ElevenLabs account के लिए voice cloning और voice management को स्वचालित करना
How ElevenLabs Python SDK compares
ElevenLabs Python SDK alongside other open-source media model apis tools AI/TLDR tracks, ranked by GitHub stars.
| टूल | स्टार | यह क्या करता है |
|---|---|---|
| ElevenLabs Python SDK | ★ 3.2k | ElevenLabs voice API के लिए आधिकारिक Python client: स्पीच सिंथेसिस, streaming, voice cloning और voice agents |
| MiniMax MMX-CLI | ★ 2.2k | आधिकारिक MiniMax CLI, जो एजेंट और टर्मिनल को टेक्स्ट, इमेज, वीडियो, स्पीच और सर्च की सुविधा देता है |
| MiniMax MCP | ★ 1.6k | AI असिस्टेंट्स को MiniMax स्पीच, वॉइस क्लोनिंग, इमेज और वीडियो जनरेशन देने वाला आधिकारिक MCP सर्वर |
| ElevenLabs | — | AI voice platform with APIs for text-to-speech, voice cloning, dubbing, speech-to-text, and music generation across 70+ languages. |
| Deepgram | — | Enterprise voice AI APIs for real-time speech-to-text, text-to-speech, and voice agent orchestration. |
| AssemblyAI | — | Speech-to-text and speech understanding API that transcribes audio and extracts insights like sentiment and entities. |
| Stability AI | — | Generative media API for image, video, audio, and 3D generation, including Stable Diffusion and Stable Audio models. |
| Luma AI | — | Dream Machine API for generating video and images from text and image prompts. |
