Manage, search, and customize voices for text-to-speech generation
The ElevenLabs SDK provides comprehensive voice management capabilities, allowing you to list, search, customize, and manage voices for your text-to-speech projects.
from elevenlabs.types import VoiceSettings# Get default settings for a voicesettings = client.voices.settings.get("21m00Tcm4TlvDq8ikWAM")# Use custom settings for generationaudio = client.text_to_speech.convert( text="Custom voice settings in action.", voice_id="21m00Tcm4TlvDq8ikWAM", voice_settings=VoiceSettings( stability=0.5, # 0.0 to 1.0 similarity_boost=0.75, # 0.0 to 1.0 style=0.5, # 0.0 to 1.0 (if supported) use_speaker_boost=True ))
voice = client.voices.ivc.create( name="Alex", description="An old American male voice with a slight hoarseness", files=[ "./sample_0.mp3", "./sample_1.mp3", "./sample_2.mp3" ])print(f"Created voice: {voice.voice_id}")
# Add a sample to an existing voiceresponse = client.voices.samples.add( voice_id="21m00Tcm4TlvDq8ikWAM", file=open("new_sample.mp3", "rb"))# Delete a sampleclient.voices.samples.delete( voice_id="21m00Tcm4TlvDq8ikWAM", sample_id="sample_id_here")
Start with default settings and adjust incrementally
Higher stability for consistent narration
Lower stability for more expressive dialogue
Use speaker boost for better quality on challenging voices
Voice Cloning Tips
Use 3-10 high-quality samples for best results
Ensure samples have minimal background noise
Remove background noise with remove_background_noise=True
Keep sample lengths between 30 seconds and 5 minutes
Performance
# Cache voice lists to reduce API callsvoices_cache = Nonedef get_voices(): global voices_cache if voices_cache is None: response = client.voices.search(page_size=100) voices_cache = response.voices return voices_cache
Next Steps
Learn about available TTS models and their capabilities