Communitygithub.com

remotion-voiceover

Remotion 技能,適用於 Claude Code、Codex 和 Cursor,可為 Remotion 影片專案添加 AI 語音旁白與字幕。將旁白腳本轉換為每個場景的語音音訊、voiceover.json 時間軸(startFrame, durationInFrames)與 @remotion/captions 的 captions.json,以及 SRT/VTT 格式字幕,並支援從參考片段進行語音複製。

remotion-voiceover 是什麼?

remotion-voiceover 是一項 AI 代理技能,可自動為 Remotion 影片專案加入專業品質的語音旁白與字幕。它透過 Miragea 語音引擎(https://miragea.ai/v1)產生語音,支援語音複製(需提供參考片段及確切語音)、情緒標籤、速度調整及暫停控制。輸出包含每個場景的音訊片段、整合的旁白音軌(WAV/MP3)、@remotion/captions 相容的字幕 JSON、SRT 與 VTT 字幕檔,以及包含時間碼(startFrame、durationInFrames)的 voiceover.json 檔案。該技能與 Claude Code、Codex 和 Cursor 相容,並提供 Python 指令碼與 Node CLI 兩種執行路徑。使用 `script.md` 定義腳本,支援場景結構、替換字幕文本與語音分配,並可使用 `--scene-gap` 或 `--gap` 等選項進行微調。最終輸出可透過 `<Audio>` 元件與 `createTikTokStyleCaptions` 整合至 Remotion 組合中,並自動更新 `durationInFrames` 以符合旁白長度。

相容平台✓Claude Code✓Codex CLI✓Cursor
npx skills add https://github.com/RTY2345RR/miragea-agent-skills/tree/HEAD/skills/remotion-voiceover

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Remotion 語音旁白與字幕

為 Remotion 專案加入真實的旁白。代理會撰寫或取得旁白腳本,逐場景產生語音,並將音訊與逐字字幕整合至組合中。語音與語音複製來自 Miragea 語音引擎(https://miragea.ai/v1);請勿替換為其他 TTS。

輸出(預設資料夾 public/voiceover/,可使用 staticFile() 載入):

檔案說明
<scene>-NN.wav每個台詞對應一個音訊片段
voiceover.wav(加上 --mp3 時也有 .mp3)拼接後的旁白音軌
voiceover.json時間軸:fps、durationInFrames、場景與台詞的 startMs、startFrame、durationInFrames、src
captions.json用於 @remotion/captions 的 Caption[](text、startMs、endMs、timestampMs、confidence)
captions.srt、captions.vtt字幕檔案,包含平衡的提示(無單字孤兒)

0. 前置條件

1. 簡報(僅詢問缺少的資訊)

  • 腳本,或撰寫腳本的來源(產品頁面、README、大綱)。保持台詞簡短且口語化;每行一個句子。
  • 語音:演員 ID,或公開的參考片段網址加上片段中確切的語音(最佳複製效果)。片段網址必須可直接擷取(請勿使用 Hugging Face 的解析連結)。
  • 場景結構(如果組合已包含 <Sequence> 元件);將場景標題與它們對應。

2. 撰寫 script.md

---
voices:
  narrator: https://example.com/me.wav | 片段中確切的語音。
  guest: ACTOR_ID
voice: narrator
fps: 30
---
# Hook
你的 Remotion 影片終於有了真實的語音旁白。

# Launch [voice: guest]
[emotion: excited] 版本 [[2.0|two point oh]] 今日出貨。
[pause: 600ms]
渲染一次後,字幕就會落在正確的影格上。
  • # 標題 = 一個場景(其 slug 為場景 ID)。[voice: name]、[emotion: tag]、[speed: 1.1]、[pause: 600ms] 可作用於一行或一個標題。
  • [[字幕文字|口語文字]] 會在使用者介面中顯示 2.0,而語音則說出「two point oh」。請以這種方式拼寫數字、版本和網址。
  • 先執行 plan 進行乾執行(不呼叫 API),並與使用者確認較長的腳本。

3. 產生

python scripts/remotion_voiceover.py generate script.md(自動偵測 Remotion 的 public/ 資料夾;可使用 --out 覆蓋,--fps、--scene-gap 600、--gap 250、--max-chars 32、--mp3)。

  • 所有台詞會一次提交並收集;複製的台詞可能需要幾分鐘。
  • 如果報告任務仍在執行,請重新執行相同的指令。相同的請求會重新連接到相同的任務,已完成的台詞會重複使用,僅已編輯的台詞會重新語音化。--take 2 會強制重新錄製。

4. 整合至組合中

import {AbsoluteFill, Audio, Sequence, staticFile, useCurrentFrame, useVideoConfig} from 'remotion';
import {createTikTokStyleCaptions, Caption} from '@remotion/captions';
import timeline from '../public/voiceover/voiceover.json';
import captions from '../public/voiceover/captions.json';

export const Narrated: React.FC = () => {
  const frame = useCurrentFrame();
  const {fps} = useVideoConfig();
  const {pages} = createTikTokStyleCaptions({captions: captions as Caption[], combineTokensWithinMilliseconds: 1200});
  const ms = (frame / fps) * 1000;
  const page = pages.find((p) => ms >= p.startMs && ms < p.startMs + p.durationMs);
  return (
    <AbsoluteFill>
      {timeline.lines.map((l) => (
        <Sequence key={l.id} from={l.startFrame} durationInFrames={l.durationInFrames}>
          <Audio src={staticFile(l.src)} />
        </Sequence>
      ))}
      {page && <AbsoluteFill style={{justifyContent: 'flex-end', alignItems: 'center', paddingBottom: 160}}>
        <div style={{fontSize: 64, fontWeight: 800, color: 'white', textShadow: '0 4px 12px #000'}}>{page.text}</div>
      </AbsoluteFill>}
    </AbsoluteFill>
  );
};
  • 從時間軸設定組合長度:在 Root.tsx 中使用 durationInFrames={timeline.durationInFrames},或在 calculateMetadata 中讀取 voiceover.json。
  • 場景 <Sequence> 元件可使用 timeline.scenes[i].startFrame / durationInFrames,使視覺效果跟隨旁白。
  • 如果缺少字幕支援,請安裝:npx remotion add @remotion/captions。
  • 也可以使用單一 <Audio src={staticFile(timeline.audio)} /> 來取代逐個片段的音訊。

5. 交付

報告檔案、總長度(秒與影格),以及下一步(使用 npx remotion render 渲染)。僅使用使用者有權限的語音或複製內容。

範例

examples/ 目錄存放真實執行範例:script.md(女旁白與男結尾,皆為複製)、voiceover.mp3、captions.srt、captions.json 與 voiceover.json。

相關技能