Communitygithub.com

iamaanahmad/voiceover-tts

生成并计时旁白,支持文本转语音(ElevenLabs、OpenAI TTS、Kokoro、Piper)或准备录制的人声——脚本准备、逐场景音频文件、语速控制、发音优化、音频清理和响度调整。当用户需要配音、旁白、拟音或语音克隆指导时使用。

voiceover-tts 是什么?

该技能(Voiceover and TTS)专为需要生成旁白或配音的开发者设计,支持多种文本转语音引擎(ElevenLabs、OpenAI TTS、Kokoro、Piper)以及录制人声的处理。它提供从脚本准备、逐场景音频文件生成、语速控制(140-160 wpm)、发音优化,到音频清理(噪声去除、压缩、响度标准化)和最终组装的完整工作流。技能基于云端API(如ElevenLabs REST调用)或本地开源工具(如Kokoro、Piper)实现,兼容Claude Code、Cursor、Codex等AI代理平台,帮助用户高效创建高质量旁白,同时强调语音克隆的伦理与法律合规要求。

兼容平台~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 密钥保存在环境变量或 .env 文件中(该文件应被 git 忽略)。切勿打印或提交它们。

为语音准备脚本

  • 将数字、单位和缩写写成口语形式:例如“twenty twenty-six”(2026年)、“A P I”(如果应逐个字母读出)、“gigabytes”(千兆字节)。
  • 添加逗号表示呼吸停顿;使用句号表示结束;避免使用括号。
  • 将难读的名称放入发音列表,并先用一个短样本进行测试。
  • 拆分为 每场景一个文件(audio/scene-01.mp3)。按场景拆分文件可让你重新录制单行,并保持时间安排灵活。

生成(示例:ElevenLabs REST)

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 wpm,请以稍有不同的方式重新生成,或删减文本;否则听起来会过于急促。
  • 不要将语音时间拉伸超过约 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.

相关技能