Communitygithub.com

iamaanahmad/voiceover-tts

使用文字轉語音(ElevenLabs、OpenAI TTS、Kokoro、Piper)生成並計時旁白,或準備錄製的聲音,包括腳本準備、每場景音訊檔案、節奏、發音、清理和音量處理。當使用者需要旁白、配音、語音克隆指導時使用。

voiceover-tts 是什麼?

這個技能專注於為影片或專案生成高品質的旁白與文字轉語音(TTS)。它支援多種引擎,包括雲端服務如 ElevenLabs 和 OpenAI TTS,以及本地方案如 Kokoro 和 Piper,涵蓋從自然語音到離線運算的不同需求。技能提供完整的腳本準備指引,如正確書寫數字和縮寫、加入逗號控制呼吸、將旁白拆分為每個場景一個音訊檔案,以便靈活調整和重新錄製。此外,它還包含實際的程式碼範例(如使用 ElevenLabs REST API)、音訊測量與調整方法(例如透過 ffprobe 檢查字數每分鐘速度),以及音訊清理腳本(如高頻濾波、降噪和標準化音量)。最後,技能強調倫理與合法使用,包括語音克隆需取得明確同意、揭露合成語音身份、以及檢查 TTS 供應商的商業授權條款。

相容平台~Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/iamaanahmad/agents-video-editing-skills/tree/HEAD/skills/voiceover-tts

在你喜歡的 AI 中提問

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

說明文件

旁白與文字轉語音(TTS)

旁白驅動時間軸。請在製作視覺素材前先生成旁白。

選擇引擎

引擎位置優點注意事項
ElevenLabs雲端 API最佳自然度、語音克隆付費;僅克隆你已獲得同意的聲音
OpenAI TTS雲端 API簡單、穩定聲音選擇有限
Kokoro本機免費、品質佳、離線可用需要 Python 設定
Piper本機快速、可在 CPU 上執行表現力較弱
錄製的人聲麥克風最真實需要清理

請將 API 金鑰儲存在環境變數或已加入 .gitignore 的 .env 檔案中。切勿列印或提交它們。

準備文字稿以利語音合成

  • 將數字、單位和縮寫寫成口語形式,例如:"twenty twenty-six"、"A P I"(如果要逐字母拼讀)、"gigabytes"。
  • 加入逗號以表示換氣;使用句號表示停頓;避免使用括號。
  • 將難以發音的名稱放入發音清單,並先以簡短樣本測試。
  • 將內容拆分為每個場景一個檔案(audio/scene-01.mp3)。每個場景的獨立檔案讓你可以重新錄製單行,並保持時間上的靈活性。

生成(以 ElevenLabs REST API 為例)

import os, requests, pathlib

def tts(text: str, voice_id: str, out: pathlib.Path) -> None:
    r = requests.post(
        f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}",
        headers={"xi-api-key": os.environ["ELEVENLABS_API_KEY"], "Accept": "audio/mpeg"},
        json={"text": text, "model_id": "eleven_multilingual_v2",
              "voice_settings": {"stability": 0.5, "similarity_boost": 0.75}},
        timeout=120,
    )
    r.raise_for_status()
    out.write_bytes(r.content)

模型名稱和端點會變更。使用前請與供應商的最新文件確認。

測量與調整節奏

ffprobe -v error -show_entries format=duration -of default=nw=1:nk=1 audio/scene-01.mp3
  • 目標速度為每分鐘 140 到 160 字(字數 / 秒數 * 60)。如果某個場景超過每分鐘 180 字,請以稍有不同的語調重新生成或刪減文字;否則聽起來會很急促。
  • 不要將語音時間拉伸超過約 10%;這會聽起來不自然。請改用重寫的方式。

清理錄製的聲音

# 高通濾波、輕量降噪、壓縮、音量標準化
ffmpeg -i raw.wav -af "highpass=f=80,afftdn=nf=-25,acompressor=threshold=-18dB:ratio=3:attack=5:release=80,loudnorm=I=-16:TP=-1.5:LRA=11" -ar 48000 clean.wav

去除開頭和結尾的靜音:

ffmpeg -i in.wav -af "silenceremove=start_periods=1:start_threshold=-45dB,areverse,silenceremove=start_periods=1:start_threshold=-45dB,areverse" out.wav

組裝

# 以 0.4 秒間隔連接場景檔案
python - <<'PY'
import subprocess, pathlib
files = sorted(pathlib.Path("audio").glob("scene-*.mp3"))
parts = []
for i, f in enumerate(files):
    parts += ["-i", str(f)]
n = len(files)
filt = "".join(f"[{i}:a]apad=pad_dur=0.4[a{i}];" for i in range(n)) + "".join(f"[a{i}]" for i in range(n)) + f"concat=n={n}:v=0:a=1[out]"
subprocess.run(["ffmpeg", "-y", *parts, "-filter_complex", filt, "-map", "[out]", "voiceover.mp3"], check=True)
PY

接著,在 audio-mixing 中與音樂混合,並使用 captions-subtitles 加入字幕。

倫理與權利

  • 僅在獲得說話者明確同意後才能克隆其聲音。
  • 在平台規則或法律要求時,揭露合成語音的使用。
  • 檢查 TTS 供應商的授權條款,確認是否允許商業用途。

Individual skills in this repo

This repo contains 6 individual skills — each has its own dedicated page.

iamaanahmad/captions-subtitles

Create, edit, translate and burn in captions and subtitles - transcribe speech with Whisper, write SRT/VTT/ASS files, style them, and hard-burn word-highlight captions for Shorts, Reels and TikTok. Use for any captioning, subtitle, transcript or accessibility request.

iamaanahmad/ffmpeg-essentials

Core FFmpeg and ffprobe recipes for trimming, joining, converting, resizing, compressing, speed changes, fades, audio extraction and GIF conversion. Use for any direct media transformation task, or when a video will not play, has odd dimensions, or is out of sync.

iamaanahmad/motion-design-craft

Motion design rules for programmatic and edited video - durations, easing, springs, staggering, read time for on-screen text, beat grids, transitions and visual hierarchy, plus the defaults that make a video look AI-generated. Use when animating scenes, choosing timings, or reviewing a video that feels off.

iamaanahmad/moviepy-python-video

Compose and edit video in pure Python with moviepy 2.x - overlay text, lower thirds and captions on footage, cut and join clips, add audio, build short single-file build.py videos without Node. Use when the user wants Python-based video editing or deterministic text over AI-generated video.

iamaanahmad/remotion-programmatic-video

Build videos as React code with Remotion - compositions, sequences, springs, interpolation, audio sync, data-driven props, studio preview and rendering to MP4. Use for explainers, product demos, release notes, data charts, branded templates, or any video that should be reproducible from code.

iamaanahmad/screen-recording-demos

Record clean product and web app demos - scripted browser recording with Playwright, cursor and zoom polish, speed ramps, trimming dead time and syncing to narration. Use when the user wants a walkthrough, tutorial, UI demo or release video of a web app, or a repeatable recording.

相關技能