Communitygithub.com

lknvt/uni-reels

使用 ElevenLabs AI 生成专业配音。当用户需要为视频创建配音、音频旁白或文本转语音内容时使用。支持多种声音和角色预设(旁白、销售员、专家),实现自然流畅的语音输出,并支持单场景重新生成以进行精细调整。

uni-reels 是什么?

该技能通过 ElevenLabs API 为 Remotion 视频生成专业级 AI 配音。它提供了一个命令行工具,可从文本、文件或 JSON 场景文件生成配音,支持多种预设角色风格,如旁白、销售员、专家等。技能的核心优势在于场景级生成与“请求拼接”(request stitching)功能,能够为整个视频项目生成音调一致的多个音频片段,并在场景间保持自然过渡。此外,它支持单场景重新生成,方便在不重做整个项目的情况下微调特定部分,以及缩略图嵌入功能,可将自定义缩略图添加到 MP4 视频中。技能还内置了基于 ffprobe 的时序验证,能自动检查音频时长偏差、沉默片段和语速,确保配音与视频画面精确同步。该工具支持 macOS、Linux、Windows,依赖 Node.js 和 ffmpeg。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/lknvt/uni-reels/tree/HEAD/.claude/skills/elevenlabs-remotion

在你喜欢的 AI 中提问

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

文档

ElevenLabs 配音生成

使用 ElevenLabs API 为 Remotion 视频生成专业 AI 配音。

先决条件

  • 在 .env.local 中设置 ELEVENLABS_API_KEY

快速开始

# 从文本生成配音
node .claude/skills/elevenlabs-remotion-skill/generate.js --text "您的文字内容" --output public/audio/voiceover.mp3

# 使用旁白风格(更自然)
node .claude/skills/elevenlabs-remotion-skill/generate.js --text "您的文字" --character narrator --output voiceover.mp3

# 使用请求拼接生成场景
node .claude/skills/elevenlabs-remotion-skill/generate.js --scenes remotion/scenes.json --output-dir public/audio/project/

# 重新生成单个场景
node .claude/skills/elevenlabs-remotion-skill/generate.js --scenes scenes.json --scene scene2 --new-text "更新后的文字"

# 列出可用声音和角色预设
node .claude/skills/elevenlabs-remotion-skill/generate.js --list-voices
node .claude/skills/elevenlabs-remotion-skill/generate.js --list-characters

角色预设

使用角色预设可以生成更自然的配音,而不仅仅是逐字朗读屏幕文本:

角色描述最佳用途
literal完全按原文朗读屏幕文本、引用
narrator专业讲述者,流畅、引人入胜解说视频、纪录片
salesperson热情、有说服力、充满活力营销、广告
expert权威、自信、知识渊博法律内容、教程
conversational随意、友好、自然社交媒体、轻松内容
dramatic强烈、情感化、有冲击力钩子、问题陈述
calm舒缓、 reassuring、温和建立信任、结尾总结
# 全局使用旁白风格
node .claude/skills/elevenlabs-remotion-skill/generate.js --scenes scenes.json --character narrator --output-dir public/audio/

# 或在 scenes.json 中为每个场景设置
{
  "scenes": [
    { "id": "scene1", "text": "问题陈述", "character": "dramatic" },
    { "id": "scene2", "text": "解决方案", "character": "calm" }
  ]
}

基于场景的生成与请求拼接

使用 ElevenLabs 请求拼接功能生成多个场景,并保持一致的韵律:

scenes.json 格式

{
  "name": "产品演示",
  "voice": "George",
  "character": "narrator",
  "scenes": [
    {
      "id": "scene1",
      "text": "通用文本转语音听起来很机械。您的品牌值得更好的。",
      "duration": 4.5,
      "character": "dramatic"
    },
    {
      "id": "scene2",
      "text": "通过语音克隆,您可以使用自己的声音制作无限量的内容。",
      "duration": 5.5
    },
    {
      "id": "scene3",
      "text": "录制一个简短的样本。克隆它。几分钟内创建专业配音。",
      "duration": 6,
      "delay": 0.3
    }
  ]
}

生成所有场景

node .claude/skills/elevenlabs-remotion-skill/generate.js \
  --scenes remotion/product-demo-scenes.json \
  --output-dir public/audio/product-demo/

这将创建:

  • product-demo-scene1.mp3 到 sceneN.mp3
  • product-demo-combined.mp3(所有场景拼接)
  • product-demo-info.json(包含时长的元数据)

单场景重新生成

如果场景开始过早、时机不对或需要不同文本:

# 使用新文本重新生成场景2
node .claude/skills/elevenlabs-remotion-skill/generate.js \
  --scenes remotion/scenes.json \
  --scene scene2 \
  --new-text "更新后的场景2文本" \
  --output-dir public/audio/project/

# 使用不同角色重新生成场景3
node .claude/skills/elevenlabs-remotion-skill/generate.js \
  --scenes remotion/scenes.json \
  --scene scene3 \
  --character salesperson \
  --output-dir public/audio/project/

# 仅重新生成(相同文本和角色)
node .claude/skills/elevenlabs-remotion-skill/generate.js \
  --scenes remotion/scenes.json \
  --scene scene1 \
  --output-dir public/audio/project/

# 将缩略图嵌入到 MP4 视频中
node .claude/skills/elevenlabs-remotion-skill/generate.js \
  --embed-thumbnail public/videos/my-video.mp4 \
  --thumbnail public/videos/my-thumbnail.png \
  --output public/videos/my-video-with-thumb.mp4

该工具自动:

  • 使用前续场景的请求拼接以保持一致的韵律
  • 使用新元数据更新 info.json 文件
  • 如果提供了 --new-text,则更新 scenes.json

缩略图嵌入

将缩略图图像嵌入到 MP4 视频中,这样 Twitter、YouTube 和视频播放器等平台会显示您自定义的缩略图,而不是第一帧。

将缩略图嵌入视频

# 基本用法 - 输出为 video-thumb.mp4
node .claude/skills/elevenlabs-remotion-skill/generate.js \
  --embed-thumbnail public/videos/promo.mp4 \
  --thumbnail public/videos/thumbnail.png

# 自定义输出路径
node .claude/skills/elevenlabs-remotion-skill/generate.js \
  --embed-thumbnail public/videos/promo.mp4 \
  --thumbnail public/videos/thumbnail.png \
  --output public/videos/promo-final.mp4

与 Remotion 配合使用的工作流程

# 1. 渲染您的视频
npx remotion render MyVideo public/videos/my-video.mp4

# 2. 渲染您的缩略图(使用 Still 合成)
npx remotion still MyVideoThumbnail public/videos/my-thumbnail.png

# 3. 嵌入缩略图
node .claude/skills/elevenlabs-remotion-skill/generate.js \
  --embed-thumbnail public/videos/my-video.mp4 \
  --thumbnail public/videos/my-thumbnail.png \
  --output public/videos/my-video-final.mp4

支持的格式

  • 视频:MP4 (H.264/H.265)
  • 缩略图:PNG、JPG、JPEG

嵌入过程使用 ffmpeg 的 -disposition:v:1 attached_pic 标志将缩略图设置为附加图片,大多数视频播放器和平台都能识别。

时序验证

该技能在生成后使用 ffprobe 自动验证时序:

检查项目

检查项阈值描述
时长偏差>15%如果实际时长与预期相差超过 15% 则发出警告
前导静音>200ms音频开始延迟(配音延迟)
尾部静音>500ms结尾存在不必要的静音
语速2-4.5 词/秒最佳约 3 词/秒

验证现有音频

# 验证项目中的所有场景
node .claude/skills/elevenlabs-remotion-skill/generate.js --validate public/audio/product-demo/

输出示例:

🔍 验证 product-demo(6 个场景)

❌ scene1: 3.00s(预期:4.5s)
   ❌ 音频比预期短 1.50s
   👍 8 个词 @ 3.1 词/秒
⚠️ scene2: 6.35s(预期:5.5s)
   ⚠️ 前导静音:235ms(可能开始较晚)
   🐢 10 个词 @ 1.8 词/秒
✅ scene4: 4.36s(预期:4s)
   👍 9 个词 @ 2.3 词/秒

📊 总时长:30.80s(预期:30.00s)

更新后的 info.json

验证后,info.json 包含实际测量值:

{
  "scenes": [
    {
      "id": "scene1",
      "duration": 4.5,
      "actualDuration": 3.0,
      "leadingSilence": 0.05,
      "wordsPerSecond": 3.1
    }
  ]
}

在 Remotion 合成中使用 actualDuration 以实现精确同步。

选项

选项描述默认值
--text, -t要转换为语音的文本必填(或 --file/--scenes)
--file, -f从文件读取文本-
--output, -o输出文件路径output.mp3
--output-dir场景的输出目录public/audio
--voice, -v声音名称或 IDGeorge
--model, -m模型 IDeleven_multilingual_v2
--character, -c角色预设literal
--scenes包含场景的 JSON 文件-
--scene重新生成的单场景 ID-
--new-text场景重新生成的新文本-
--validate验证现有音频目录-
--skip-validation跳过自动验证false
--embed-thumbnail要嵌入缩略图的视频文件-
--thumbnail缩略图图像文件 (PNG/JPG)-
--stability声音稳定性 (0-1)因角色而异
--similarity声音相似度 (0-1)因角色而异
--style风格夸张度 (0-1)因角色而异
--no-combined跳过组合文件false

推荐声音

声音风格最佳用途
George温暖、迷人的英式英语旁白、解说视频
Antoni专业、温暖法律内容、教程
Arnold权威、深沉企业、严肃话题
Josh友好、健谈营销、休闲内容

与 Remotion 集成

生成场景配音后,在您的合成中使用它们:

import { Audio, Sequence, staticFile } from "remotion";

// 使用单个场景音频文件实现精确同步
const SCENE_DURATIONS = {
  scene1: 4.5,  // 来自 info.json
  scene2: 5.5,
  scene3: 8.0,
};

export const VideoWithVoiceover: React.FC = () => {
  const { fps } = useVideoConfig();

  const scene1Frames = Math.round(SCENE_DURATIONS.scene1 * fps);
  const scene2Frames = Math.round(SCENE_DURATIONS.scene2 * fps);

  return (
    <>
      <Sequence from={0} durationInFrames={scene1Frames}>
        <Audio src={staticFile("audio/project/project-scene1.mp3")} />
        <Scene1Visual />
      </Sequence>

      <Sequence from={scene1Frames} durationInFrames={scene2Frames}>
        <Audio src={staticFile("audio/project/project-scene2.mp3")} />
        <Scene2Visual />
      </Sequence>
    </>
  );
};

获得最佳效果的提示

  1. 使用角色预设:不要逐字朗读屏幕文本 - 使用 narrator 或 expert 以获得自然流畅的效果
  2. 标点符号很重要:使用句号表示停顿,逗号表示短暂间歇
  3. 数字:写出数字(“五百”而非“500”)以获得自然语音
  4. 缩写:写完整的单词(“二十四小时”而非“24h”)
  5. 逐场景处理:不同场景可以使用不同角色(戏剧性开场、平静的 CTA)
  6. 精细调整:使用 --scene 重新生成单个场景,无需重做所有内容
  7. 请求拼接:保持所有场景语音一致

工作流程示例

# 1. 使用您的脚本创建 scenes.json
# 2. 以旁白风格生成所有场景
node .claude/skills/elevenlabs-remotion-skill/generate.js \
  --scenes remotion/my-video-scenes.json \
  --character narrator \
  --output-dir public/audio/my-video/

# 3. 在 Remotion 中预览,发现场景2开始过早
# 4. 仅使用更新后的文本重新生成场景2
node .claude/skills/elevenlabs-remotion-skill/generate.js \
  --scenes remotion/my-video-scenes.json \
  --scene scene2 \
  --new-text "稍长一些的文本来填充视觉效果的时间" \
  --output-dir public/audio/my-video/

# 5. 使用 info.json 中的新时长更新视频合成
# 6. 重复直到时机完美

Individual skills in this repo

This repo contains 1 individual skill — each has its own dedicated page.

相关技能