Sound Effects
作者: ElevenLabs
使用ElevenLabs根据文本描述生成音效。适用于创建音效、生成音频纹理、制作环境音、电影冲击音、界面音效或任何非语音音频。支持循环播放、时长控制及提示影响调节。
npx skills add https://github.com/elevenlabs/skills --skill sound-effectsElevenLabs Sound Effects
Generate sound effects from text descriptions — supports looping, custom duration, and prompt adherence control.
Setup: See Installation Guide. For JavaScript, use
@elevenlabs/*packages only.
Quick Start
Python
from elevenlabs import ElevenLabs
client = ElevenLabs()
audio = client.text_to_sound_effects.convert(
text="Thunder rumbling in the distance with light rain",
)
with open("thunder.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.textToSoundEffects.convert({
text: "Thunder rumbling in the distance with light rain",
});
audio.pipe(createWriteStream("thunder.mp3"));
cURL
curl -X POST "https://api.elevenlabs.io/v1/sound-generation" \
-H "xi-api-key: $ELEVENLABS_API_KEY" -H "Content-Type: application/json" \
-d '{"text": "Thunder rumbling in the distance with light rain"}' \
--output thunder.mp3
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
text | string (required) | — | Description of the desired sound effect |
model_id | string | eleven_text_to_sound_v2 | Model to use |
duration_seconds | number | null | null (auto) | Duration 0.5–30s; auto-calculated if null |
prompt_influence | number | null | 0.3 | How closely to follow the prompt (0–1) |
loop | boolean | false | Generate a seamlessly looping sound (v2 model only) |
Examples with Parameters
# Looping ambient sound, 10 seconds
audio = client.text_to_sound_effects.convert(
text="Gentle forest ambiance with birds chirping",
duration_seconds=10.0,
prompt_influence=0.5,
loop=True,
)
# Short UI sound, high prompt adherence
audio = client.text_to_sound_effects.convert(
text="Soft notification chime",
duration_seconds=1.0,
prompt_influence=0.8,
)
Output Formats
Pass output_format as a query parameter (cURL) or SDK parameter:
| Format | Description |
|---|---|
mp3_44100_128 | MP3 44.1kHz 128kbps (default) |
pcm_44100 | Raw uncompressed CD quality |
opus_48000_128 | Opus 48kHz 128kbps — efficient compressed |
ulaw_8000 | μ-law 8kHz — telephony |
Full list: mp3_22050_32, mp3_24000_48, mp3_44100_32, mp3_44100_64, mp3_44100_96, mp3_44100_128, mp3_44100_192, pcm_8000, pcm_16000, pcm_22050, pcm_24000, pcm_32000, pcm_44100, pcm_48000, ulaw_8000, alaw_8000, opus_48000_32, opus_48000_64, opus_48000_96, opus_48000_128, opus_48000_192.
Prompt Tips
- Be specific: "Heavy rain on a tin roof" > "Rain"
- Combine elements: "Footsteps on gravel with distant traffic"
- Specify style: "Cinematic braam, horror" or "8-bit retro jump sound"
- Mention mood/context: "Eerie wind howling through an abandoned building"
Error Handling
try:
audio = client.text_to_sound_effects.convert(text="Explosion")
except Exception as e:
print(f"API error: {e}")
Common errors:
- 401: Invalid API key
- 422: Invalid parameters (check duration range, prompt_influence range)
- 429: Rate limit exceeded
References
来自 ElevenLabs 的更多技能
Setup API Key
ElevenLabs
引导用户完成设置ElevenLabs API密钥的过程,以便与ElevenLabs MCP工具配合使用。当用户需要配置ElevenLabs API密钥、因缺少API密钥导致ElevenLabs工具失败,或用户提到需要访问ElevenLabs时使用。
development
Agents
ElevenLabs
使用ElevenLabs构建语音AI代理。适用于创建语音助手、客服机器人、交互式语音角色或任何实时语音对话体验。
developmentofficial
Music
ElevenLabs
使用ElevenLabs Music API生成音乐。适用于创作器乐、带歌词的歌曲、背景音乐、广告曲或任何AI生成的音乐作品。支持基于提示词的生成、用于精细控制的作曲方案,以及包含元数据的详细输出。
developmentofficial
Speech To Text
ElevenLabs
使用ElevenLabs Scribe v2将音频转录为文本。适用于将音频/视频转换为文字、生成字幕、转录会议或处理语音内容。
developmentofficial
Text To Speech
ElevenLabs
使用ElevenLabs语音AI将文本转换为语音。适用于从文本生成音频、创建配音、构建语音应用或合成70多种语言的语音。
developmentofficial