Communitygithub.com

ElevenLabs 語音旁白生成

使用 ElevenLabs AI 生成專業的語音旁白。適用於需要為影片、音訊旁白或文字轉語音內容製作旁白的場景。支援多種語音及角色預設(旁白、銷售員、專家),可實現自然的語調。包含單一場景重新生成功能,方便微調。

ElevenLabs 語音旁白生成 是什麼?

這是一個專為 Remotion 影片製作設計的 ElevenLabs 語音旁白生成技能,能透過 ElevenLabs API 將文字轉換為高品質、自然的 AI 語音旁白。它不僅支援基本的文字轉語音,更提供多種角色預設(例如旁白、銷售員、專家、戲劇化、冷靜等),讓旁白風格更符合影片內容,而非只是機械式地朗讀字幕。此外,技能支援基於場景的批次生成,可一次處理多個場景的文字,並透過 ElevenLabs 的請求拼接(request stitching)技術,確保跨場景的語調與節奏一致性。單一場景重新生成功能,則讓使用者在發現某個場景的旁白時機、文字或角色不對時,能單獨修正而不必重新生成所有內容。技能也內建了時間驗證機制,自動檢查旁白長度、前後靜音時間及說話速率,並提供修正資訊。同時,它還能將縮圖嵌入 MP4 影片中,讓社群平台或播放器顯示自訂縮圖而非第一影格。此技能支援 Claude Code、Cursor 與 Codex 等開發工具,並以 Node.js 腳本執行,整合 Remotion 專案流程。

相容平台✓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平穩、安撫、溫和建立信任、結語
# 全域使用旁白風格
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": "product-demo",
  "voice": "George",
  "character": "narrator",
  "scenes": [
    {
      "id": "scene1",
      "text": "Generic text-to-speech sounds robotic. Your brand deserves better.",
      "duration": 4.5,
      "character": "dramatic"
    },
    {
      "id": "scene2",
      "text": "With voice cloning, you can use your own voice for unlimited content.",
      "duration": 5.5
    },
    {
      "id": "scene3",
      "text": "Record a short sample. Clone it. Create professional voiceovers in minutes.",
      "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(包含持續時間的中繼資料)

單一場景重新產生

如果某個場景開始得太早、時機錯誤或需要不同的文字:

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

# 使用不同角色重新產生 scene3
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%當實際長度與預期長度差異過大時發出警告
前端靜音>200ms音訊開始得太晚(旁白延遲)
尾端靜音>500ms結尾有不必要的靜音
說話速度2-4.5 wps最佳約每秒 3 個單字

驗證現有音訊

# 驗證專案中的所有場景
node .claude/skills/elevenlabs-remotion-skill/generate.js --validate public/audio/product-demo/

輸出範例:

🔍 Validating product-demo (6 scenes)

❌ scene1: 3.00s (expected: 4.5s)
   ❌ Audio 1.50s shorter than expected
   👍 8 words @ 3.1 words/sec
⚠️ scene2: 6.35s (expected: 5.5s)
   ⚠️ Leading silence: 235ms (may start late)
   🐢 10 words @ 1.8 words/sec
✅ scene4: 4.36s (expected: 4s)
   👍 9 words @ 2.3 words/sec

📊 Total duration: 30.80s (expected: 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 中預覽,發現 scene2 開始得太早
# 4. 僅重新產生 scene2,並使用更新後的文字
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.

相關技能