技能圖譜SKILLSGROVE
技能圖譜/短影片與自媒體/0xSero/youtube-translate-skill/youtube-translate

youtube-translate

安裝

$npx skills add https://github.com/0xSero/youtube-translate-skill --skill youtube-translate
$git clone --depth 1 https://github.com/0xSero/youtube-translate-skill.git /tmp/youtube-translate-skill && mkdir -p ~/.claude/skills && cp -r /tmp/youtube-translate-skill/. ~/.claude/skills/youtube-translate
請幫我安裝這個 Agent Skill:https://github.com/0xSero/youtube-translate-skill/tree/51fa9371983c8d500b3dc7e02167ab532d7d79c7/ ,先閱讀它的 SKILL.md 和指令碼,確認安全後再安裝到我的技能目錄。

簡介

原文描述 · MITGiven YouTube links (videos, channels, playlists) or local folders/files (subtitles or media), produce per-language translated SRT subtitle files (default en, uk, de, fr, es, pl) ready to upload to YouTube, plus accuracy QA. Works with any OpenAI-compatible endpoint, or with no endpoint at all — the calling model does the translation itself. Not for dubbing/voice-over, video editing, or titles/thumbnails.
以下 SKILL.md 內容轉載自 0xSero/youtube-translate-skill(提交 51fa937),依據 MIT 許可證轉載正文(文字未改動;僅省略檔案頭後設資料、將圖片顯示為連結,超長內容會截斷);版權歸 2025 youtube-translate-skill contributors 所有。許可證:LICENSE。僅展示說明檔案,附帶指令碼請在原倉庫檢視。

YouTube / media → translated subtitles

Everything is in scripts/. Requirements: python3 (stdlib only) and yt-dlp on PATH for YouTube inputs. Translation is done either by an OpenAI-compatible endpoint or by you, the calling model. Local media without subtitles is transcribed only if an ASR tool is installed (faster-whisper, mlx_whisper, or the whisper CLI); otherwise that item is marked needs-asr and the run continues.

Inputs

Pass any mix of:

  • YouTube video, channel (https://youtube.com/@Handle, /videos, /streams), or playlist URLs. --latest N = newest N per channel/playlist (0 = all).
  • Local folders or files: .srt, .vtt, YouTube .json3, or media (.mp4/.mkv/.mov/.webm/.mp3/.m4a/.wav). A sidecar subtitle with the same stem is used when present; otherwise media is transcribed (if an ASR tool exists).

--langs sets target codes (default en,uk,de,fr,es,pl); the source language is skipped automatically.

Output (per item, stable across re-runs)

<out>/<source>/<YYYYMMDD>_<slug>_<id>/
  video.json               metadata, cues, status
  original-script.md       full original transcript in paragraphs
  original.<src>.srt       timed original captions
  translations/<lang>.srt  one SRT per target language, same cues/timings
  translations/<lang>.md   readable transcript in that language (same paragraph breaks as original-script.md)

Mode A — you have an OpenAI-compatible endpoint

export YT_TX_BASE_URL=http://<host>:<port>/v1 YT_TX_API_KEY=<key> YT_TX_MODEL=<served-model>
python3 scripts/yt_translate.py run <inputs...> --langs en,uk,de --out ./out --concurrency 8

Re-running is safe: finished <lang>.srt files are skipped and every chunk is cached under <video>/.cache/.

Mode B — no endpoint: you translate (agent mode)

  1. prepare — ingest and write numbered work items (no network model needed for translation):
    python3 scripts/yt_translate.py prepare <inputs...> --langs en,uk,de --out ./out
    
    This writes, per video and language, chunks at <video>/.work/<lang>/<n>.in.json:
    {"_meta": {"source_language": "...", "target_language": "...", ...},
     "1": "first source line", "2": "second source line", ...}
    
  2. translate each work item yourself. For every <n>.in.json:
    • Read it. Translate each numbered value from _meta.source_language into _meta.target_language.
    • Lines are consecutive speech fragments; a sentence may span lines — translate so they read naturally in order.
    • Write <n>.out.json next to it: the same numbered keys (no _meta), each value a non-empty translated string.
    • Fan this out with subagents or parallel calls if your harness supports it — the items are independent.
  3. check what's left (optional): python3 scripts/yt_translate.py status --out ./out lists pending items.
  4. assemble — validate every .out.json and write the SRTs:
    python3 scripts/yt_translate.py assemble --out ./out
    
    Any item with missing/extra keys or empty values is reported as invalid; incomplete languages are reported and skipped. Fix those .out.json files and run assemble again.

Accuracy QA

# structural only (always available, no model):
python3 scripts/qa.py run ./out --sample 0
# with an endpoint GEMBA-MQM judge (use a DIFFERENT model than the translator if you can):
export YT_QA_BASE_URL=... YT_QA_MODEL=... YT_QA_API_KEY=...
python3 scripts/qa.py run ./out --sample 40 --review en,uk
# agent-mode judge (no endpoint): prepare -> fill qa/.judge/*/1.out.json -> assemble
python3 scripts/qa.py prepare ./out --sample 40
python3 scripts/qa.py assemble ./out

The judge follows GEMBA-MQM (Kocmi & Federmann, 2023): per line it lists errors by category (accuracy/mistranslation, omission, addition, terminology, fluency/grammar) × severity (critical 25 / major 5 / minor 1). Line score = 100 − penalties, clipped at 0. Outputs: qa/report.md, qa/flags.jsonl, qa/judge.jsonl, qa/review-*.md.

Upload to YouTube

YouTube Studio → Subtitles → the video → Add language → Upload file → "With timing" → translations/<lang>.srt.

Known failures

  • Members-only/private videos fail in yt-dlp ("Join this channel…") and are logged; the rest continue.
  • Videos with captions disabled (or music only) end up no-captions.
  • Dubbed videos expose several *-orig ASR tracks; only the declared-language one is the true original.
  • Some videos need cookies: set YT_DLP_COOKIES_FROM_BROWSER (e.g. chrome, brave:Profile 1) or YT_DLP_COOKIES (a cookies.txt path).
檢視許可證全文(MIT)
MIT License

Copyright (c) 2025 youtube-translate-skill contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.