Communitygithub.com

YouTube 视频转录

使用 OpenAI Whisper 和 yt-dlp 将 YouTube 视频转录为文本。当用户需要从 YouTube 视频获取转录文本、生成字幕、将视频语音转换为文本、创建 SRT/VTT 字幕或提取 YouTube URL 中的语音内容时使用。

YouTube 视频转录 是什么?

该技能利用 yt-dlp 从 YouTube 视频下载音频,并通过 OpenAI 的 Whisper 模型进行转录。支持多种输出格式(txt、srt、vtt、json)以及不同大小的模型(tiny、base、small、medium、large),用户可根据准确性和速度需求进行选择。该技能提供完整的命令行和 Python 集成方案,包括一次性下载和转录管道,以及更简单的 yt-whisper 工具。适用于各种场景,如生成纯文本转录、带时间戳的字幕、多语言转录(如西班牙语)。支持所有主要平台(macOS、Linux、Windows),需要安装 ffmpeg 进行音频处理。对于英语内容,可使用英语专用模型(如 tiny.en)以获得更快的速度和更高的准确性;GPU(CUDA)可显著加速转录过程。

兼容平台~Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/youtube-transcription

在你喜欢的 AI 中提问

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

文档

YouTube 视频转录 是做什么的?

使用 OpenAI Whisper 和 yt-dlp 将 YouTube 视频转录为文本。

概述

该技能使用 yt-dlp 从 YouTube 视频下载音频,并利用 OpenAI 的 Whisper 模型进行转录。支持多种输出格式(txt、srt、vtt、json)以及不同大小的模型,以适应不同的准确性和速度需求。

操作说明

1. 安装依赖

# 安装 whisper 和 yt-dlp
pip install openai-whisper yt-dlp

# 验证 ffmpeg 是否已安装(音频处理必需)
ffmpeg -version

如果缺少 ffmpeg:

2. 从 YouTube 下载音频

# 下载最佳音频质量并保存为 WAV 格式
yt-dlp -x --audio-format wav -o "%(title)s.%(ext)s" "YOUTUBE_URL"

# 下载为 MP3 格式(文件更小)
yt-dlp -x --audio-format mp3 -o "%(title)s.%(ext)s" "YOUTUBE_URL"

# 使用视频 ID 作为文件名(避免特殊字符问题)
yt-dlp -x --audio-format wav -o "%(id)s.%(ext)s" "YOUTUBE_URL"

3. 选择 Whisper 模型

模型参数规模VRAM相对速度使用场景
tiny39M~1 GB~32x快速草稿、测试
base74M~1 GB~16x快速转录
small244M~2 GB~6x良好的平衡
medium769M~5 GB~2x高准确性
large1550M~10 GB1x最佳准确性

英语专用模型(tiny.en、base.en、small.en、medium.en)在处理英语内容时速度更快。

4. 运行转录

命令行方式:

# 基本转录(自动检测语言)
whisper audio.wav --model medium

# 指定语言以获得更好的准确性
whisper audio.wav --model medium --language en

# 输出特定格式
whisper audio.wav --model medium --output_format srt

# 一次性输出所有格式
whisper audio.wav --model medium --output_format all

# 指定输出目录
whisper audio.wav --model medium --output_dir ./transcripts

Python 方式:

import whisper

# 加载模型(首次运行时会自动下载)
model = whisper.load_model("medium")

# 转录
result = model.transcribe("audio.wav", language="en")

# 获取纯文本
print(result["text"])

# 获取带时间戳的片段
for segment in result["segments"]:
    print(f"[{segment['start']:.2f} - {segment['end']:.2f}] {segment['text']}")

5. 一行命令管道

将下载和转录合并:

# 在一行命令中下载并转录
yt-dlp -x --audio-format wav -o "audio.wav" "YOUTUBE_URL" && whisper audio.wav --model medium --output_format all

6. 替代方案:yt-whisper 工具

如需更简单的工作流程,可使用专用的 yt-whisper 包:

# 安装
pip install git+https://github.com/m1guelpf/yt-whisper.git

# 直接从 URL 转录
yt_whisper "https://www.youtube.com/watch?v=VIDEO_ID"

# 带选项
yt_whisper "YOUTUBE_URL" --model medium --language en --output_format srt

输出格式

格式扩展名描述
txt.txt纯文本转录
srt.srtSubRip 字幕格式(带时间戳)
vtt.vttWebVTT 字幕格式
tsv.tsv制表符分隔的值
json.json包含单词级时间戳的完整数据

示例

指南

  • 当你知道视频所用语言时,请使用 --language 标志,以便显著提高准确性
  • 对于长时间视频(超过 1 小时),请使用 small 或 medium 模型以平衡速度和准确性
  • 英语专用模型(带有 .en 后缀)在处理英语内容时速度更快且更准确
  • 配备 CUDA 的 GPU 可大幅提升转录速度;CPU 也能工作,但速度慢 5-10 倍
  • 如果转录失败,请确保 ffmpeg 已正确安装并在 PATH 中
  • 对于带有背景音乐的视频,较大的模型(medium/large)处理效果更好
  • 转录后清理音频文件以节省磁盘空间
  • 使用 --output_format all 一次性获取所有格式,然后根据需要选择

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- Automate motion capture and tracking workflows in Blender with Python. Use when the user wants to import BVH or FBX mocap data, retarget motion to armatures, track camera or object motion from video, solve camera motion, clean up motion capture data, or script any tracking pipeline in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

Data Version Control for ML projects. Track large datasets and models alongside Git, build reproducible ML pipelines, and run experiments with metric comparison. Works with any storage backend including S3, GCS, Azure, and local filesystems.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Transcode, convert, edit, and process audio and video with FFmpeg. Use when a user asks to convert video formats (webm to mp4, mkv to mp4), extract audio from video, compress video files, trim or cut clips, concatenate videos, add subtitles, create thumbnails, apply filters, change resolution or bitrate, re-encode media, create GIFs from video, add watermarks, normalize audio, stream media, or build automated media processing pipelines.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium.

相关技能