Documentation Index Fetch the complete documentation index at: https://mintlify.com/elevenlabs/elevenlabs-python/llms.txt
Use this file to discover all available pages before exploring further.
Generate professional-quality sound effects for your videos, games, podcasts, and voice-overs using the most advanced sound effects AI models.
Quick Start
from elevenlabs import ElevenLabs
client = ElevenLabs( api_key = "YOUR_API_KEY" )
# Generate a sound effect
audio = client.text_to_sound_effects.convert(
text = "thunder crashing in the distance" ,
duration_seconds = 3.0
)
# Save to file
with open ( "thunder.mp3" , "wb" ) as f:
for chunk in audio:
f.write(chunk)
Features
Natural Sounds Generate realistic environmental sounds like rain, wind, or thunder
Seamless Looping Create sound effects designed to loop smoothly
Custom Duration Specify exact duration for your sound effects
High Quality Professional-grade audio output in multiple formats
Basic Usage
Generate a Sound Effect
from elevenlabs import ElevenLabs
client = ElevenLabs( api_key = "YOUR_API_KEY" )
audio = client.text_to_sound_effects.convert(
text = "waves crashing on a beach" ,
duration_seconds = 5.0
)
with open ( "waves.mp3" , "wb" ) as f:
for chunk in audio:
f.write(chunk)
Create Looping Sound Effects
# Generate a seamlessly looping sound
audio = client.text_to_sound_effects.convert(
text = "gentle rain falling" ,
duration_seconds = 10.0 ,
loop = True # Optimized for seamless looping
)
with open ( "rain_loop.mp3" , "wb" ) as f:
for chunk in audio:
f.write(chunk)
Parameters
Text Description
The text parameter accepts natural language descriptions of the sound you want to create:
# Environmental sounds
client.text_to_sound_effects.convert( text = "wind howling through trees" )
# Mechanical sounds
client.text_to_sound_effects.convert( text = "old door creaking open" )
# Nature sounds
client.text_to_sound_effects.convert( text = "birds chirping in the morning" )
# Urban sounds
client.text_to_sound_effects.convert( text = "city traffic ambience" )
Duration Control
# Short sound effect (1 second)
audio = client.text_to_sound_effects.convert(
text = "door knock" ,
duration_seconds = 1.0
)
# Medium sound effect (5 seconds)
audio = client.text_to_sound_effects.convert(
text = "rain ambience" ,
duration_seconds = 5.0
)
# Long ambient sound (30 seconds)
audio = client.text_to_sound_effects.convert(
text = "ocean waves" ,
duration_seconds = 30.0
)
Prompt Influence
Control how closely the generation follows your text description:
# High influence - very literal interpretation
audio = client.text_to_sound_effects.convert(
text = "glass breaking" ,
prompt_influence = 0.9
)
# Medium influence - balanced
audio = client.text_to_sound_effects.convert(
text = "footsteps on gravel" ,
prompt_influence = 0.5
)
# Low influence - more creative interpretation
audio = client.text_to_sound_effects.convert(
text = "mysterious atmosphere" ,
prompt_influence = 0.2
)
# MP3 format (default)
audio = client.text_to_sound_effects.convert(
text = "thunder" ,
output_format = "mp3_22050_32"
)
# High-quality MP3
audio = client.text_to_sound_effects.convert(
text = "thunder" ,
output_format = "mp3_44100_192" # Requires Creator tier or above
)
# PCM format for editing
audio = client.text_to_sound_effects.convert(
text = "thunder" ,
output_format = "pcm_44100" # Requires Pro tier or above
)
Async Usage
from elevenlabs import AsyncElevenLabs
import asyncio
async def generate_sound_effect ():
client = AsyncElevenLabs( api_key = "YOUR_API_KEY" )
audio = await client.text_to_sound_effects.convert(
text = "explosion in the distance" ,
duration_seconds = 3.0
)
chunks = []
async for chunk in audio:
chunks.append(chunk)
return b "" .join(chunks)
audio_data = asyncio.run(generate_sound_effect())
Batch Generation
Generate multiple sound effects efficiently:
from elevenlabs import AsyncElevenLabs
import asyncio
async def generate_multiple_effects ():
client = AsyncElevenLabs( api_key = "YOUR_API_KEY" )
sound_descriptions = [
"thunder" ,
"rain" ,
"wind" ,
"fire crackling"
]
tasks = [
client.text_to_sound_effects.convert(
text = desc,
duration_seconds = 5.0
)
for desc in sound_descriptions
]
results = await asyncio.gather( * tasks)
# Save each sound effect
for i, (desc, audio) in enumerate ( zip (sound_descriptions, results)):
chunks = []
async for chunk in audio:
chunks.append(chunk)
with open ( f " { desc.replace( ' ' , '_' ) } .mp3" , "wb" ) as f:
f.write( b "" .join(chunks))
asyncio.run(generate_multiple_effects())
Use Cases
Video Production
# Generate ambient background sounds
ambient = client.text_to_sound_effects.convert(
text = "busy coffee shop atmosphere" ,
duration_seconds = 30.0 ,
loop = True
)
# Generate specific action sounds
action = client.text_to_sound_effects.convert(
text = "car door slam" ,
duration_seconds = 2.0
)
Game Development
# Background ambience
forest_ambience = client.text_to_sound_effects.convert(
text = "forest with birds and insects" ,
duration_seconds = 60.0 ,
loop = True
)
# Interactive sounds
footsteps = client.text_to_sound_effects.convert(
text = "footsteps on wooden floor" ,
duration_seconds = 1.0
)
Podcast Production
# Intro/outro sounds
intro = client.text_to_sound_effects.convert(
text = "upbeat notification sound" ,
duration_seconds = 2.0
)
# Transition effects
transition = client.text_to_sound_effects.convert(
text = "swoosh transition" ,
duration_seconds = 1.0
)
Best Practices
Writing Effective Descriptions
Be specific about the sound you want
Include details about intensity, distance, and environment
Use descriptive adjectives (“loud”, “gentle”, “distant”)
Mention specific objects or actions (“glass shattering”, “metal clanging”)
Short effects (0.5-2s): Impacts, hits, notifications
Medium effects (3-10s): Transitions, specific actions
Long effects (15-60s): Ambient backgrounds, atmospheres
Use looping for continuous backgrounds
Limitations
Maximum duration may vary based on your subscription tier
High-quality formats (192kbps MP3, PCM, WAV) require higher subscription tiers
Generation time increases with duration