YouTube视频转录工具

这是一个通过 Gemini API 将 YouTube 视频直接转换为带时间戳文本转录的服务,提供 Python 库、CLI 和 MCP 服务器多种使用方式,适用于生成字幕、内容摘要和视频引用。

  • by JorgeAGR
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 JorgeAGR/gemini-youtube-transcriber-mcp

使用说明

gemini-youtube-transcriber

Transcribes YouTube videos using the Gemini API, exposed as both a Python library and an MCP server.

Why Gemini?

Gemini has native, first-party access to YouTube — it can read and process a YouTube video directly from its URL, with no downloading, no intermediate storage, and no third-party tooling required. You pass a URL, Gemini watches the video (at FPS<1 and low-resolution to save on tokens, as this is an audio-centric task), and returns a transcription. This keeps the implementation minimal and the latency low.

Output format

Each line of the transcription follows a consistent, machine-readable format:

MM:SS: <text>

When multiple speakers are distinguishable:

MM:SS: Speaker A: <text>
MM:SS: Speaker B: <text>

Installation

pip install .

Requires a Gemini API key. Set it as an environment variable:

export GEMINI_API_KEY="your-key-here"

Optionally, override the Gemini model (default: gemini-3-flash-preview):

export GEMINI_MODEL="gemini-3.1-flash-lite-preview"

Usage

CLI

transcribe https://www.youtube.com/watch?v=EFMy5atDfMw

By default this writes a text file named after the video ID and the UTC time of the run — EFMy5atDfMw_20260916T142317Z.txt — in the current directory.

Use -o/--output to choose the path, or - to print to stdout instead:

transcribe -o notes.txt https://www.youtube.com/watch?v=EFMy5atDfMw
transcribe -o - https://www.youtube.com/watch?v=EFMy5atDfMw | less

Python

from youtube_transcriber import transcribe_youtube

transcript = transcribe_youtube("https://www.youtube.com/watch?v=...")
print(transcript)

mcpb (Claude Desktop)

Download the latest .mcpb file from the Releases page and open it — Claude Desktop will install the extension automatically and prompt you for your Gemini API key.

MCP server

python -m youtube_transcriber.server

Register in your MCP client config:

{
  "mcpServers": {
    "youtube-transcriber": {
      "command": "python",
      "args": ["-m", "youtube_transcriber.server"],
      "env": {
        "GEMINI_API_KEY": "your-key-here",
        "GEMINI_MODEL": "gemini-3-flash-preview"
      }
    }
  }
}

The MCP tool transcribe_youtube_video accepts a YouTube URL and returns the full transcription string.

mcpb

A manifest.json is included for one-click installation via mcpb. mcpb will prompt you for your Gemini API key and handle the rest — no manual config editing required.

mcpb install .