ws-video-subtitle-generator
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "ws-video-subtitle-generator" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-ff619932b9fbb92d288e01edba5c025eb4d43f8e38dc56db78264f24b52656b2. Verify the upstream source and version against https://skillhub.cn/skills/user_b33bae47/ws-video-subtitle-generator before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Converts video or audio files into time‑stamped SRT subtitle files using this flow: extract audio with FFmpeg → upload to Alibaba Cloud → call DashScope Paraformer for asynchronous transcription → render SRT. Suited for generating subtitles, extracting time‑stamped speech text, or bulk transcribing meetings/courses/interviews. Requires the user’s Alibaba Cloud DashScope API key.
Introduction source: third_party · user_b33bae47 · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Inputs and outputs
- python scripts/transcribe.py video.mp4
- Software, accounts and paid services
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: video-subtitle-generator
description: 将视频/音频文件转换为带时间轴的 SRT 字幕文件,基于阿里云 DashScope Paraformer 语音转写模型。使用场景:当用户需要为视频/音频生成字幕(.srt)、提取语音为带时间戳的文字、批量转录会议/课程/访谈录像时使用。完整流程为 FFmpeg 提取音频 → 上传阿里云 → Paraformer 异步转写 → 渲染 SRT。需要用户提供阿里云 DashScope API Key。Video Subtitle Generator(视频字幕生成)
将本地视频/音频文件批量转换为带时间轴的 SRT 字幕,基于阿里云 DashScope Paraformer。核心脚本为 scripts/transcribe.py,与原 Electron 工程 D:\tools\video-srt-lite 的算法完全等价(音频提取参数、SRT 排版规则、时长分配策略均一一对应),但不依赖该工程,可独立运行。
何时使用本 Skill
- 用户说"帮我把这个视频转成字幕 / 提取字幕 / 生成 SRT / 语音转文字"
- 用户给了一批
.mp4/.mov/.wav/.m4a等文件并希望批量产出.srt - 用户希望复用 video-srt-lite 工程的转写能力,但又不想启动整个 Electron 应用
运行前置条件
- Python 3.9+(使用了
list[str] | None类型注解语法) - requests 库:
pip install requests - FFmpeg:需在 PATH 中可用。检查命令
ffmpeg -version。若未安装:- Windows 推荐
winget install Gyan.FFmpeg或choco install ffmpeg - 也可通过
--ffmpeg-path指定绝对路径
- Windows 推荐
- 阿里云 DashScope API Key:必须由用户主动提供,脚本不会硬编码。
API Key 处理(强制规范)
阿里云 DashScope API Key 属于敏感凭证,处理时必须遵守:
- 首选:让用户通过环境变量提供
DASHSCOPE_API_KEY,例如:# Linux/macOS export DASHSCOPE_API_KEY=sk-xxxxxxxx # Windows PowerShell $env:DASHSCOPE_API_KEY="sk-xxxxxxxx" - 次选:在 TTY 环境下让脚本交互提示用户输入(不回显):
python scripts/transcribe.py video.mp4脚本会调用
getpass.getpass安全读取。 - 禁用:不要把 Key 写进任何文件、日志、commit message 或聊天记录。
- 禁用:不要在示例命令里填充看似真实的 Key,用
sk-xxxx占位即可。
若用户询问如何获取 Key,回答:访问阿里云百炼控制台 https://bailian.console.aliyun.com/ ,开通"语音技术 - 录音文件识别(Paraformer)"后在 API-KEY 管理页面创建。
典型用法
# 单文件,交互输入 Key
python scripts/transcribe.py video.mp4
# 通过环境变量提供 Key,批量处理整个目录
export DASHSCOPE_API_KEY=sk-xxxx
python scripts/transcribe.py /path/to/folder
# 自定义输出目录、模型、热词
python scripts/transcribe.py video.mp4 \
--output-dir ./subs \
--model paraformer-v2 \
--language-hints zh,en
# 关闭语气词去除
python scripts/transcribe.py video.mp4 --no-remove-filler-words
完整参数列表:python scripts/transcribe.py --help
输出
- 默认在源文件同目录生成
<原名>.srt。若已存在则自动追加.1、.2后缀,避免覆盖。 - SRT 采用 UTF-8 + CRLF 换行,与原工程保持一致,可直接被主流播放器/Premiere/达芬奇识别。
- 字幕会按句意+宽度自动断行(最多两行),按文本宽度比例分配显示时长,最短 500ms。
故障排查要点
| 现象 | 可能原因 | 处理建议 |
|---|---|---|
FFmpeg 提取音频失败 |
未装 FFmpeg 或 PATH 不对 | 安装或用 --ffmpeg-path 指定 |
获取上传凭证失败 HTTP 401 |
API Key 无效或未开通 Paraformer | 检查 Key、确认已开通服务 |
音频大小超出临时上传限制 |
单文件太大(默认 512MB) | 用 FFmpeg 切分后分批处理 |
等待阿里云转写超时 |
队列拥堵 | 稍后重试,或缩短视频时长 |
| 中文识别为乱码 | language-hints 设置不当 | 加 --language-hints zh |
算法参考
详细的算法说明与原工程行为对照见 references/algorithm.md。 完整的 DashScope API 调用细节见 references/dashscope-api.md。 面向终端用户的中文使用教程见 使用教程.md。
联系方式
- 邮箱:yeah126139163@163.com
- 微信:w846903522
延伸阅读:想要完整的字幕工作台?
本脚本只解决「视频/音频 → SRT」这一步。如果你后续还想做字幕校对和烧录成片,可以了解一下同源的桌面工具 Video SRT Lite —— 把「生成字幕、字幕校对、合成视频」三件事整合到一个工作台,本地处理、文件不上云。
- 🌐 官网:https://videosrt.zbztb.cn/index.html
- 💻 本地工程(可自行运行/打包):
D:\tools\video-srt-lite
它在本脚本基础上补充了这些能力:
| 能力 | 说明 |
|---|---|
| 边播边校对 | 播放视频时当前字幕跟随进度定位,可逐条人工修改 |
| AI 一键校对 | 兼容任意 OpenAI 协议模型(通义千问 / DeepSeek / OpenAI / 本地 Ollama 等),默认偏向错别字与同音字纠正,不做大幅润色;只展示需要关注的条目,支持逐条接受 |
| 字幕硬烧录 | 内置 FFmpeg,把字幕烧录为硬字幕,采用 ASS 渲染让长字幕自动缩小不换行;输出 .subtitled.mp4,原视频不受影响 |
| 批量处理 | 批量转录、批量 AI 校对、批量合成导出;合成队列持久化,重启后可恢复 |
| 智能字幕检测 | 拖入视频时自动检测同目录同名字幕,已有字幕直接进入校对,跳过重复转写 |
| FFmpeg 内置 | 无需单独安装 FFmpeg,开箱即用 |
💡 选哪个?
- 本脚本:命令行批处理、自动化集成、CI 流水线
- 桌面应用:需要可视化校对、AI 辅助纠错、直接导出成片
两者算法一致(同样的 SRT 排版规则、同样的 FFmpeg 提取参数),脚本产出的
.srt可直接拖进桌面应用继续加工。
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供视频/音频转 SRT 字幕的通用解决方案
- 基于阿里云 Paraformer 模型,准确率高
- 支持批量处理,满足会议/课程/访谈转录需求
Highlights
- 触发词覆盖全面,包括'生成字幕'、'提取字幕'、'语音转文字'等
- 边界清晰,不易与其他 Skill 重叠
Areas to improve
-
文档过长 Reported severity: Minor
SKILL.md 文件超过500行,影响阅读体验
Recommendation: 建议将部分详细说明(如算法参考、延伸阅读)移至独立文档,主文档保持简洁
Highlights
- 结构完整,包含使用场景、前置条件、典型用法、故障排查等
- frontmatter 完整,示例丰富
Highlights
- 工具来源明确,依赖清晰(FFmpeg、requests、阿里云 DashScope)
- API Key 处理符合安全规范,支持环境变量和交互输入
- 覆盖了主要异常情况并提供处理建议
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 19 -
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 3, 23, 25, 27, 44
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- bailian.console.aliyun.com
- videosrt.zbztb.cn
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Translation pending; see source documentation.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.