Communitygithub.com

Oussamaosman02/motion-video-playbook

根据文本描述生成音效,使用ElevenLabs。适用于创建音效、生成音频纹理、环境音、电影冲击音、UI音效或任何非语音音频。支持循环播放、时长控制和提示影响调整。

motion-video-playbook 是什么?

这是一个由ElevenLabs驱动的音效生成技能,开发者可以通过简单的文本描述快速创建各种音频效果。该技能支持Python、JavaScript和CLI三种使用方式,并提供了丰富的参数控制,包括时长范围(0.5–30秒)、提示影响度(0–1)以及循环播放功能(仅v2模型)。用户还可以选择多种输出格式,如MP3、PCM、Opus等。此外,技能文档提供了详细的提示词技巧(如具体描述和风格指定)和错误处理示例,帮助开发者高效生成高质量的音效。支持平台包括ElevenLabs SDK和CLI工具。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Oussamaosman02/motion-video-playbook/tree/HEAD/skills/opcional-elevenlabs/sound-effects

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

ElevenLabs 音效生成

根据文本描述生成音效 — 支持循环播放、自定义时长和提示影响控制。

设置: 请参阅安装指南。对于 JavaScript,请仅使用 @elevenlabs/* 包。

快速开始

Python

from elevenlabs import ElevenLabs

client = ElevenLabs()

audio = client.text_to_sound_effects.convert(
    text="远处雷声隆隆,伴有细雨"
)

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: "远处雷声隆隆,伴有细雨",
});
audio.pipe(createWriteStream("thunder.mp3"));

CLI

elevenlabs text-to-sound-effects convert \
  --text "远处雷声隆隆,伴有细雨" \
  --output thunder.mp3

参数

参数类型默认值描述
textstring (必需)—所需音效的描述
model_idstringeleven_text_to_sound_v2使用的模型
duration_secondsnumber | nullnull (自动)时长 0.5–30s;如果为 null 则自动计算
prompt_influencenumber | null0.3对提示的遵循程度 (0–1)
loopbooleanfalse生成无缝循环音效(仅 v2 模型)

带参数的示例

# 循环环境音,10秒
audio = client.text_to_sound_effects.convert(
    text="轻柔的森林氛围,鸟鸣声",
    duration_seconds=10.0,
    prompt_influence=0.5,
    loop=True,
)

# 短 UI 音效,高提示遵循度
audio = client.text_to_sound_effects.convert(
    text="轻柔的通知提示音",
    duration_seconds=1.0,
    prompt_influence=0.8,
)

输出格式

传递 --output-format(CLI)或 output_format 作为 SDK 参数:

格式描述
mp3_44100_128MP3 44.1kHz 128kbps(默认)
pcm_44100原始未压缩 CD 质量
opus_48000_128Opus 48kHz 128kbps — 高效压缩
ulaw_8000μ-law 8kHz — 电话音质

完整列表: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.

提示词技巧

  • 具体描述:"铁皮屋顶上的大雨" > "雨"
  • 组合元素:"砾石上的脚步声,远处有车流"
  • 指定风格:"电影爆音,恐怖" 或 "8位复古跳跃音效"
  • 提及情绪/背景:"废弃建筑中诡异的呼啸风声"

错误处理

try:
    audio = client.text_to_sound_effects.convert(text="爆炸声")
except Exception as e:
    print(f"API 错误:{e}")

常见错误:

  • 401:API 密钥无效
  • 422:参数无效(检查时长范围、提示影响范围)
  • 429:超出速率限制

参考资料

相关技能