Communitygithub.com

boyingliu01/bilingual-video-subtitles

为培训/讲解视频自动添加中英文双语字幕(转写+翻译+硬字幕合成),并按主题/角色拆分成 10 分钟以内短视频。Use when 用户要求:给视频加中英字幕、培训视频双语字幕、视频转写并翻译英文字幕、外籍员工字幕支持、把培训视频按主题/角色/章节拆分成短视频、碎片化学习视频切分,或每年制度修订后对培训视频字幕做微调并重新渲染。核心能力:Qwen3-Omni 结合参考文档/制度文档做高精度中文转写(解决 whisper/funasr 专业术语识别差的问题),faster-whisper 提取时间轴,拼音全局对齐,术语表驱动的中译英,输出双语 SRT + 硬字幕视频 + 可编辑字幕工程文件(支持后续微调重渲染,无需重新转写)。命令:python3 scripts/pipeline.py build|render|split|status。

bilingual-video-subtitles 是什么?

bilingual-video-subtitles is a Codex agent skill that 为培训/讲解视频自动添加中英文双语字幕(转写+翻译+硬字幕合成),并按主题/角色拆分成 10 分钟以内短视频。Use when 用户要求:给视频加中英字幕、培训视频双语字幕、视频转写并翻译英文字幕、外籍员工字幕支持、把培训视频按主题/角色/章节拆分成短视频、碎片化学习视频切分,或每年制度修订后对培训视频字幕做微调并重新渲染。核心能力:Qwen3-Omni 结合参考文档/制度文档做高精度中文转写(解决 whisper/funasr 专业术语识别差的问题),faster-whisper 提取时间轴,拼音全局对齐,术语表驱动的中译英,输出双语 SRT + 硬字幕视频 + 可编辑字幕工程文件(支持后续微调重渲染,无需重新转写)。命令:python3 scripts/pipeline.py build|render|split|status。.

兼容平台~Claude Code✓Codex CLI~Cursor
npx skills add boyingliu01/bilingual-video-subtitles

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Bilingual Video Subtitles 培训视频双语字幕

The complete pipeline is in scripts/pipeline.py (single entry point with caching support for resume after interruption).

Host environment note: This skill is adapted for cross-environment operation; the transcription backend is automatically selected (original sandbox Omni gateway / OpenAI-compatible API / whisper bridge). If no Omni gateway is available and no API backend is configured, it falls back to agent mode — the transcribe/translate stages pause with exit code 3 and write out a manifest. After completing the corresponding transcription/translation, rerun build to resume. Read the operational protocol and backend configuration guide at references/host-adaptation.md. Encountering pipeline exit 3 is not a failure; complete the work indicated in the manifest and rerun.

Standard Workflow

  1. Obtain input: video file + corresponding regulatory/guidelines documents (.docx/.txt/.md).
  2. Read the reference document and create a glossary glossary.txt (one line per entry: Chinese = English, 10–40 entries). The glossary determines the translation consistency across the entire video. Must cover: system/policy names, roles and acronyms (e.g., PM=Project Manager), business forms or form names, internal system names.
  3. Execute the build (run in foreground with sufficient timeout; a 50-minute video full workflow takes about 15–25 minutes):
python3 scripts/pipeline.py build \
  --video <video path> --doc <document path> \
  --work <working directory> --out <output directory> \
  --glossary <glossary.txt> \
  --hotwords "安全红线,需求单,变更单,PM,QA,SRE" \
  --preview 90
  1. Generation sequence (each step is cached; rerun the same command after a failure to resume): setup (audio segmentation) → transcribe (Qwen3-Omni full manuscript) → timing (whisper timestamps) → align (pinyin alignment) → clean (remove filler words, split sentences) → translate (batch Chinese-to-English) → package (project file + SRT + ASS) → render (preview + full version).
  2. Use the preview video output from --preview to confirm the effect with the user (you can use media-read to check frame samples for subtitle rendering), then deliver the full video, SRT, and subtitle project file.

Deliverables

FilePurpose
<name>_中英双语字幕_完整版.mp4Hard-subtitled final video (Chinese in white top line, English in light blue bottom line, both with a semi-transparent black background bar, readable on any background)
<name>_中英双语字幕.srtBilingual subtitle file (can be imported into players/platforms)
<name>_字幕工程.jsonMaster data: contains all timestamps + bilingual text. Only this file is modified for annual adjustments.
--work directoryIntermediate cache (transcription, whisper timestamps). Keep to avoid re-transcription.

Annual Fine-Tuning (Updating Subtitles After Policy Revisions)

When policy changes affect only a few sentences, do not re-transcribe:

  1. Ask the user to point out the timespan/content to modify, or directly edit the zh/en text in the previous year's <name>_字幕工程.json (do not modify start/end timestamps if unchanged).
  2. Re-render:
python3 scripts/pipeline.py render --project <project.json> [--video <new video>] [--srt-only]

If the new video has added/removed sentences in corresponding chapters: run build --stage transcribe on the new video to get the new manuscript, manually compare and replace the corresponding entries in the project file, then render.

Splitting Videos by Topic/Role (Microlearning)

Based on the fully subtitled, full-length video (preserving bilingual subtitles).

  1. Locate chapter boundaries from the subtitle data: use the role/chapter list from the reference document as keywords to search for chapter transition sentences in zh_lines.json (working directory). Typical patterns: "The Nth role is X", "Above are the responsibilities of X, the requirement is:", "Violations for X are:", etc. Use the start time of the transition sentence as the split point (that sentence belongs to the next clip).
  2. Constraints: Each clip ≤10 minutes (hard limit 15 minutes); if a chapter exceeds the limit, split within the chapter at natural boundaries (e.g., between "Duties/Violations/Determination Methods"); do not merge different roles.
  3. Write a split plan JSON and execute:
{"base": "video_name", "lead_in": 0.35,
 "chapters": [{"start": 0, "end": 288.4,
               "title": "01_Introduction_Purpose and Overview", "note": "Content description"}]}
python3 scripts/pipeline.py split --plan plan.json \
  --video <subtitled_full_video.mp4> --out <output directory>
  1. Output to <output directory>/<video_name>_splits/: automatically named clips + 00_split_manifest.txt (clip name, time range, duration, content description).
  2. Spot check: Extract frames (ffmpeg PNG capture) at the beginning of each clip to verify the split point lands exactly on the corresponding topic's opening sentence.

Key Implementation Constraints (Do Not Deviate)

  • The qwen-omni backend must inject the full reference document into the prompt as terminology context, with --timeout 900 --max-tokens 8192 (script has this built-in); API backends with dedicated ASR (e.g., mimo-asr) cannot accept text prompts, so terminology correction relies on the clean stage cross-referencing the document.
  • whisper is used only for timestamps; its transcribed text is discarded entirely (Chinese text quality is poor, but timestamps are accurate).
  • Alignment must use pinyin-based global alignment (homophone errors are automatically resolved at the pinyin level); greedy per-sentence alignment causes global drift.
  • Alignment quality: align output qual mean ≥0.75 is normal; if <0.6, first check whisper voice coverage (see references/troubleshooting.md).
  • For long-duration CPU-intensive tasks (whisper/render), be aware of the host's background task cleanup strategy; run in foreground if necessary.
  • Network restrictions: HuggingFace requires a mirror; the script already has HF_ENDPOINT=hf-mirror.com and HF_HUB_DISABLE_XET=1 set; do not remove them.

Troubleshooting

See references/troubleshooting.md: handling upload timeouts, single long lines in transcription, low alignment quality, font garbling, render failures, etc.

相关技能