npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

openclaw-drama-generator

v2.0.0

Published

Automated drama video generator - from script to multi-character drama videos with OpenAI TTS, Whisper, and Remotion

Readme

OpenClaw Drama Generator - 短剧生成器

Tagline: 短剧生成 - 从剧本到视频,一键生成

自动化短剧视频生成系统。将剧本文本转换为多角色配音的专业短剧视频。

特性

  • 多角色对话 - 自动识别角色,分配不同声音
  • 剧本解析 - 支持标准短剧格式,自动提取场景和对话
  • 智能配音 - 基于角色自动选择合适的声音
  • 场景切换 - 美观的场景转场动画
  • 对话框样式 - 专业的对话呈现效果
  • 旁白支持 - 特殊的旁白视觉风格
  • 完全自动化 - 一行命令完成全流程

快速开始

安装

# 克隆项目
git clone https://github.com/ZhenRobotics/openclaw-drama-generator.git
cd openclaw-drama-generator

# 安装依赖
npm install

# 设置 API Key
export OPENAI_API_KEY="sk-..."

创建第一个短剧

  1. 创建剧本文件:
cat > scripts/my-drama.txt <<'EOF'
[场景1 - 办公室 - 早晨]
旁白: 又是忙碌的一天开始了。
小明: 早啊小红,今天的项目汇报准备好了吗?
小红: 准备好了,PPT我已经发到你邮箱了。

[场景2 - 会议室 - 上午]
老板: 大家好,今天我们讨论一下业绩。
小明: 老板,我们这个月的增长率达到了百分之十五。
老板: 很好,继续保持!
EOF
  1. 生成视频:
./scripts/drama-to-video.sh scripts/my-drama.txt
  1. 查看结果:
mpv out/my-drama.mp4

剧本格式

标准格式

[场景N - 地点 - 时间]
角色名: 对话内容
角色名: (情绪) 对话内容
旁白: 旁白内容

示例

[场景1 - 咖啡厅 - 下午]
旁白: 这是一个温暖的午后。
小美: 你最近怎么样?
小王: 挺好的,工作很忙。
小美: (关心) 要注意休息啊。

[场景2 - 公园 - 傍晚]
旁白: 夕阳西下,他们在公园散步。
小王: 谢谢你的关心。
小美: 朋友之间应该的。

使用方式

基础用法

# 生成短剧视频
./scripts/drama-to-video.sh scripts/my-drama.txt

# 指定语速
./scripts/drama-to-video.sh scripts/my-drama.txt --speed 1.1

# 使用其他 TTS 提供商
./scripts/drama-to-video.sh scripts/my-drama.txt --provider azure

分步执行

# 1. 解析剧本
node scripts/parse-drama-script.js scripts/my-drama.txt

# 2. 生成多角色 TTS
./scripts/drama-tts-generate.sh audio/my-drama-parsed.json

# 3. 提取时间戳
./scripts/whisper-timestamps.sh audio/drama-full.mp3

# 4. 生成场景数据
node scripts/drama-to-scenes.js \
  audio/my-drama-parsed.json \
  audio/drama-full-timestamps.json \
  audio/drama-segments.json

# 5. 渲染视频
npm run render

预览和调试

# 开发模式预览
npm run dev

# 在浏览器打开 http://localhost:3000

角色声音映射

系统会自动为角色分配声音,支持的声音包括:

| 声音 | 特点 | 适合角色 | |------|------|----------| | alloy | 中性,清晰 | 男性角色 | | echo | 男性,稳重 | 成熟男性 | | fable | 英式,优雅 | 旁白 | | onyx | 深沉,有力 | 领导/老板 | | nova | 女性,活泼 | 年轻女性 | | shimmer | 柔和,温暖 | 旁白/女性 |

自定义声音

创建角色配置文件:

{
  "小明": "alloy",
  "小红": "nova",
  "老板": "onyx",
  "旁白": "shimmer"
}

使用自定义配置:

# 修改 parse-drama-script.js 中的 voiceMapping
# 或在生成后手动编辑 *-parsed.json 文件

视觉效果

场景类型

  • 对话场景 - 对话框样式,显示角色名和对话内容
  • 场景转场 - 显示场景信息的过渡动画
  • 旁白场景 - 居中显示,引号样式

颜色方案

  • 不同角色使用不同颜色
  • 青色 (#00F5FF)
  • 品红 (#FF10F0)
  • 绿色 (#00FF00)
  • 橙色 (#FFA500)
  • 金色 (#FFD700) - 旁白专用

动画效果

  • 对话框弹出动画
  • 打字机文本效果
  • 场景淡入淡出
  • 场景转场动画

技术架构

流水线

剧本文本
  ↓
剧本解析 (parse-drama-script.js)
  ↓
多角色 TTS (drama-tts-generate.sh)
  ↓
时间戳提取 (whisper-timestamps.sh)
  ↓
场景数据生成 (drama-to-scenes.js)
  ↓
视频渲染 (Remotion)
  ↓
短剧视频

技术栈

  • React - UI 框架
  • Remotion - 视频渲染引擎
  • OpenAI TTS - 语音合成
  • OpenAI Whisper - 时间戳提取
  • FFmpeg - 音频处理
  • TypeScript - 类型安全

项目结构

openclaw-drama-generator/
├── scripts/
│   ├── drama-to-video.sh          # 完整流水线
│   ├── parse-drama-script.js      # 剧本解析器
│   ├── drama-tts-generate.sh      # 多角色 TTS
│   ├── drama-to-scenes.js         # 场景数据生成
│   └── examples/
│       └── office-drama.txt       # 示例剧本
├── src/
│   ├── DramaRoot.tsx              # Remotion 根组件
│   ├── DramaVideo.tsx             # 主视频组件
│   ├── DialogueScene.tsx          # 对话场景
│   ├── SceneTransition.tsx        # 场景转场
│   ├── NarrationScene.tsx         # 旁白场景
│   └── scenes-data.ts             # 场景数据
├── audio/                         # 音频输出
├── out/                           # 视频输出
└── docs/
    └── DRAMA_ARCHITECTURE.md      # 架构文档

示例

示例 1: 办公室短剧

# 使用预置的示例剧本
./scripts/drama-to-video.sh scripts/examples/office-drama.txt

示例 2: 自定义剧本

创建你自己的剧本,按照标准格式编写,然后运行:

./scripts/drama-to-video.sh scripts/your-drama.txt

成本估算

| 组件 | 定价 | 1分钟短剧成本 | |------|------|--------------| | OpenAI TTS | $0.015/1K字符 | ~$0.009 | | OpenAI Whisper | $0.006/分钟 | ~$0.006 | | 本地渲染 | 免费 | $0 | | 总计 | | ~$0.015 |

每个1分钟短剧成本约 1.5 美分。

性能

处理时间(1分钟短剧)

| 步骤 | 时间 | |------|------| | 剧本解析 | <1秒 | | TTS 生成 | 10-20秒 | | 时间戳提取 | 5-10秒 | | 场景生成 | <1秒 | | 视频渲染 | 30-90秒 | | 总计 | 50-120秒 |

视频规格

  • 分辨率: 1080 x 1920 (竖屏)
  • 帧率: 30 fps
  • 格式: MP4 (H.264 + AAC)
  • 时长: 根据剧本自动计算

支持的 TTS 提供商

  • OpenAI TTS (默认)
  • Azure TTS
  • 阿里云 TTS
  • 腾讯云 TTS

配置方式请参考 .env.example

故障排查

常见问题

Q: TTS 生成失败

# 检查 API Key
echo $OPENAI_API_KEY

# 测试 TTS
curl https://api.openai.com/v1/audio/speech \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"tts-1","input":"测试","voice":"nova"}' \
  --output test.mp3

Q: 音频拼接失败

# 检查 ffmpeg 是否安装
ffmpeg -version

# 手动检查音频段
ls -lh audio/segments/

Q: 视频渲染失败

# 开发模式调试
npm run dev

# 检查场景数据
cat src/scenes-data.ts

文档

未来计划

  • AI 自动生成剧本
  • 更多视觉效果模板
  • 角色头像/形象显示
  • 背景图片/视频支持
  • 情绪识别和表现
  • 多语言支持
  • 云端渲染

贡献

欢迎提交 Issue 和 Pull Request!

许可证

MIT

联系方式

  • GitHub: https://github.com/ZhenRobotics/openclaw-drama-generator
  • Issues: https://github.com/ZhenRobotics/openclaw-drama-generator/issues

用 AI 生成短剧视频,让创意变成现实!