Generate sound effects from text prompts via ElevenLabs Sound Effects API. Outputs MP3 files. Use for video SFX, UI sounds, ambient backgrounds, transition effects.
Generate sound effects from text descriptions using the ElevenLabs Sound Effects API. Outputs an MP3 file — anything from a UI click to a thunderstorm to a spaceship engine.
/sfx-elevenlabs "door creaking open in a haunted house" [--duration <seconds>] [--output <path>] [--loop]
/sfx-elevenlabs "gentle rain on a window" --duration 10 --loop
--duration — length in seconds (0.5–30). Default: auto-detected from prompt.--output — output file path. Default: /tmp/sfx-elevenlabs-<timestamp>.mp3.--loop — generate a seamlessly looping sound effect (v2 model only).--influence — prompt influence (0–1). Higher = stricter adherence to prompt. Default: 0.3.--format — output format. Default: mp3_44100_128. Options: mp3_44100_128, , .pcm_16000opus_48000_64if [ -z "$ELEVENLABS_API_KEY" ]; then
echo "❌ ELEVENLABS_API_KEY not set."
echo ""
echo "Get your key at: https://elevenlabs.io/app/settings/api-keys"
echo "Then set it: export ELEVENLABS_API_KEY=sk_..."
echo "Or add to: ~/.claude/.env"
exit 1
fi
PROMPT="$1"
DURATION="${DURATION:-null}" # null = auto-detect
INFLUENCE="${INFLUENCE:-0.3}"
LOOP="${LOOP:-false}"
MODEL="eleven_text_to_sound_v2"
FORMAT="${FORMAT:-mp3_44100_128}"
OUTPUT="${OUTPUT_PATH:-/tmp/sfx-elevenlabs-$(date +%s).mp3}"
curl -s -X POST "https://api.elevenlabs.io/v1/sound-generation?output_format=${FORMAT}" \
-H "xi-api-key: $ELEVENLABS_API_KEY" \
-H "Content-Type: application/json" \
-d "$(python3 -c "
import json, sys
data = {
'text': '''$PROMPT''',
'model_id': '$MODEL',
'prompt_influence': $INFLUENCE,
'loop': $LOOP
}
dur = $DURATION
if dur != 'null' and dur is not None:
data['duration_seconds'] = float(dur)
print(json.dumps(data))
")" \
--output "$OUTPUT"
if [ ! -f "$OUTPUT" ] || [ "$(wc -c < "$OUTPUT")" -lt 100 ]; then
echo "❌ Sound effect generation failed. Response:"
cat "$OUTPUT" 2>/dev/null
exit 1
fi
DURATION_ACTUAL=$(ffprobe -v quiet -show_entries format=duration -of csv=p=0 "$OUTPUT" 2>/dev/null | cut -d. -f1)
SIZE=$(wc -c < "$OUTPUT" | tr -d ' ')
✅ Sound effect generated
Prompt: <first 80 chars>...
Model: eleven_text_to_sound_v2
Duration: <N>s
Loop: <true|false>
Influence: <0-1>
Size: <N> KB
Output: <output path>
Play: open <output path>
# Quick test — generates a 2-second click sound
export $(grep ELEVENLABS_API_KEY ~/.claude/.env)
curl -s -X POST "https://api.elevenlabs.io/v1/sound-generation" \
-H "xi-api-key: $ELEVENLABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "short UI button click", "duration_seconds": 1, "prompt_influence": 0.5}' \
--output /tmp/sfx-test.mp3 && \
echo "✅ API key works" && open /tmp/sfx-test.mp3
| Variable | Required | Default | Description |
|---|---|---|---|
ELEVENLABS_API_KEY | yes | — | API key from elevenlabs.io/app/settings/api-keys |
eleven_text_to_sound_v2)| Category | Prompt | Duration |
|---|---|---|
| UI | "short satisfying button click" | 0.5s |
| Transition | "cinematic swoosh transition" | 2s |
| Ambient | "gentle rain on a window with distant thunder" | 15s |
| Impact | "spacious braam suitable for movie trailer" | 5s |
| Nature | "birds chirping in a morning forest" | 10s |
| Tech | "futuristic computer startup sequence" | 3s |
| Notification | "gentle chime notification sound" | 1s |
generate-video — SFX for transitions, intros, outros in Remotion videosmusic-elevenlabs — combine SFX with background music for full audio designaudio-mix — layer SFX over voice and music tracks