YouTube Transcript Fetcher (YTT)
YouTube Transcript Fetcher
Whisper AI文字起こしを使用して、あらゆるYouTube動画から文字起こしを取得します。YouTubeを検索し、上位検索結果の文字起こしを取得します。YouTube APIキーは不要です。
特徴
Whisper搭載 — 最先端のAI文字起こし、99%以上の精度
YouTube検索 — YouTubeを検索し、上位結果の文字起こしを取得
APIキー不要 — YouTube Data APIの認証情報なしで動作
複数の形式 — テキスト、JSON、SRT、VTT出力
キャッシュ機能 — SQLiteベースのキャッシュにより再文字起こしを回避
レート制限なし — Whisperがローカルで動作するため、外部APIの制限を受けない
CLI & ライブラリ — コマンドラインツールまたはPythonモジュールとして使用可能
MCPサーバー — Model Context Protocolを介してAIツールと統合
Related MCP server: youtube-mcp
インストール
# Clone the repository
git clone https://github.com/andrewctf/ytt.git
cd ytt
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/Mac
.venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Optional: GPU support
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128注: GPU/CUDAの詳細なセットアップについては、QUICKSTART.mdを参照してください。
Whisperの追加セットアップ
Whisperは音声抽出のために ffmpeg を必要とします:
Windows (wingetを使用):
winget install ffmpegmacOS:
brew install ffmpegLinux:
sudo apt install ffmpegクイックスタート
詳細なインストールおよびセットアップ手順については、QUICKSTART.mdを参照してください。
CLI
# Get transcript (Whisper is used by default)
python cli.py transcript VIDEO_ID
# Or with a full YouTube URL
python cli.py transcript "https://www.youtube.com/watch?v=a1JTPFfshI0"
# Different output formats
python cli.py transcript VIDEO_ID --format json
python cli.py transcript VIDEO_ID --format srt
python cli.py transcript VIDEO_ID --format vtt
# Save to file
python cli.py transcript VIDEO_ID --output transcript.txt
# Batch processing
python cli.py transcript VIDEO_ID1 VIDEO_ID2 VIDEO_ID3
# Search YouTube for videos and get transcripts
python cli.py search "Python tutorial" --limit 5 --with-transcripts
# Search only (no transcripts)
python cli.py search "Python tutorial" --limit 10
# JSON output for search
python cli.py search "Python tutorial" --format json
# Cache management
python cli.py cache-stats
python cli.py cache-stats --clean # Remove expired entriesPythonライブラリ
from src.service import get_transcript
from src.search_service import search, search_and_get_transcripts
# Basic usage
result = await get_transcript("VIDEO_ID")
print(result.content)
# With options
result = await get_transcript(
"VIDEO_ID",
language="en",
output_format="json",
use_cache=True,
)
# Access metadata
print(f"Source: {result.source}") # 'whisper' or 'innertube'
print(f"Language: {result.language}") # Detected language
print(f"Video ID: {result.video_id}")
# Search YouTube for videos
results = await search("Python tutorial", max_results=5)
for video in results:
print(f"{video.title} ({video.video_id}) - {video.channel_name}")
# Search and get transcripts for results
results = await search_and_get_transcripts("Python tutorial", max_results=3, language="en")
for video, transcript in results:
if transcript:
print(f"{video.title}: {transcript.content[:100]}...")同期的な使用方法:
import asyncio
from src.service import get_transcript
from src.search_service import search
def fetch_transcript(video_id):
return asyncio.run(get_transcript(video_id))
def search_videos(query, max_results=5):
return asyncio.run(search(query, max_results=max_results))
result = fetch_transcript("VIDEO_ID")
print(result.content)
videos = search_videos("Python tutorial")MCPサーバー
注: Claude Desktop、Cursor、VS Codeでの詳細な設定については、QUICKSTART.mdを参照してください。
MCPサーバーを起動します:
python -m mcp_server.serverサーバーは3つのツールを公開します:
get_transcript- 単一動画の文字起こしを取得get_transcripts_batch- 複数の動画の文字起こしを同時に取得search_videos- クエリに一致するYouTube動画を検索
または、MCP設定に追加してClaude Desktopと統合します:
{
"mcpServers": {
"yt-transcript": {
"command": "python",
"args": ["-m", "mcp_server.server"],
"cwd": "/absolute/path/to/ytt"
}
}
}仕組み
Video ID → Cache Check
↓ found?
Return Cached
↓ not found
Whisper (primary)
- Download audio via yt-dlp
- Transcribe with faster-whisper
- Returns word-level timestamps
↓ fails?
Innertube API (fallback)
- Extract API key from video page
- Fetch caption tracks
- Parse JSON3 timed text
↓
Cache Result
↓
Format & ReturnWhisper (プライマリ)
yt-dlpを使用して音声をダウンロードfaster-whisper(CPU最適化済み) を使用して文字起こし単語レベルのタイムスタンプとセグメントテキストを返却
音声があるあらゆる動画で動作
リアルタイム処理速度の約1〜3倍
Innertube API (フォールバック)
YouTubeの内部APIをスクレイピング
APIキー不要
高速 (動画あたり約0.5〜2秒)
約85%のカバー率 (一部の動画には字幕がない)
レート制限あり (IPあたり約5リクエスト/10秒)
出力形式
テキスト (デフォルト)
Good morning, here we are, a live suturing course like nobody else has ever
done and what are we covering, we're covering every suturing technique...JSON
{
"video_id": "a1JTPFfshI0",
"language": "en",
"source": "whisper",
"segments": [
{"start": 0.0, "end": 4.5, "text": "Good morning, here we are..."},
{"start": 4.5, "end": 9.2, "text": "a live suturing course..."}
]
}SRT (SubRip)
1
00:00:00,000 --> 00:00:04,500
Good morning, here we are, a live suturing course...
2
00:00:04,500 --> 00:00:09,200
a live suturing course like nobody else...VTT (WebVTT)
WEBVTT
00:00:00.000 --> 00:00:04.500
Good morning, here we are, a live suturing course...
00:00:04.500 --> 00:00:09.200
a live suturing course like nobody else...設定
config.py を編集して動作をカスタマイズします:
class Config:
# Whisper settings
WHISPER_MODEL = "base" # tiny/base/small/medium/large
WHISPER_FALLBACK_ENABLED = True
# Cache settings
CACHE_TTL_DAYS = 7
CACHE_DB_PATH = ".transcript_cache.db"
# Rate limiting (for Innertube fallback)
RATE_LIMIT_RATE = 0.5 # tokens per second
RATE_LIMIT_BURST = 5 # max bucket size
# Batch processing
MAX_BATCH_SIZE = 50Whisperモデル
モデル | 速度 | 精度 | メモリ |
tiny | 10倍 | 約75% | 約1GB |
base | 7倍 | 約85% | 約1GB |
small | 4倍 | 約90% | 約2GB |
medium | 2倍 | 約95% | 約5GB |
large | 1倍 | 約97% | 約6GB |
ほとんどのユースケースでは、高速かつ十分な精度を持つ base モデルが推奨されます。
ファイル構造
ytt/
├── src/
│ ├── __init__.py
│ ├── fetcher.py # Innertube API client
│ ├── whisper_runner.py # Whisper transcription
│ ├── parser.py # Caption parsing utilities
│ ├── formatters.py # Output formatters
│ ├── cache.py # SQLite cache
│ ├── rate_limiter.py # Token bucket
│ ├── service.py # Orchestrator
│ ├── searcher.py # YouTube search
│ ├── search_cache.py # Search result cache
│ ├── search_service.py # Search orchestrator
│ ├── cuda_dll_manager.py # Auto-download CUDA libraries
│ └── exceptions.py # Custom exceptions
├── mcp_server/
│ ├── __init__.py
│ └── server.py # FastMCP server
├── cli.py # CLI entrypoint
├── main.py # Library entrypoint
├── config.py # Configuration
├── requirements.txt # Core dependencies
├── requirements-mcp.txt # MCP dependencies
├── README.md
└── QUICKSTART.mdトラブルシューティング
"No module named 'rich'"
依存関係をインストールします:
pip install -r requirements.txtWhisperが "ffmpeg not found" で失敗する
ffmpegをインストールしてください (上記のインストールセクションを参照)。
文字起こし速度が遅い
より小さいWhisperモデルを使用する (
largeの代わりにbase)whisper_runner.py内のdevice="cpu"をdevice="cuda"に変更してGPUアクセラレーションを使用するキャッシュを有効にして再文字起こしを回避する
Innertubeからのレート制限
InnertubeフォールバックはYouTubeによってレート制限されます (約5リクエスト/10秒)。これを回避するために、プライマリ (デフォルト) としてWhisperを使用してください。キャッシュも冗長なリクエストを防ぎます。
キャッシュが機能しない
キャッシュ統計を確認します:
python cli.py cache-stats期限切れのエントリをクリーンアップします:
python cli.py cache-stats --clean開発
テストの実行
pytestコードのフォーマット
black src/
ruff check src/ライセンス
MIT License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
An MCP server that gives any LLM or agent clean YouTube transcripts on demand: a single video, a whole channel, or a playlist, plus AI cleanup of auto-generated captions. API-key auth, credit-based, same backend as the public v1 API. Get a free API key with 25 free credits at youtubetranscriptdownload.com/account.
An MCP server that provides tools to discover and retrieve podcast episodes transcripts.
MCP server for RiverScript, an AI transcription platform - fetches transcripts shared via a link.
An MCP server that provides congressional transcripts
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that enables users to retrieve YouTube transcripts and perform video or channel searches without requiring Google API keys. It supports transcript chunking and provides tools for detailed video content analysis and channel metadata extraction.5584MIT
- AlicenseAqualityCmaintenanceAn MCP server that enables the extraction of transcripts and detailed metadata from YouTube videos. It allows users to retrieve video information like titles and descriptions, as well as transcripts with optional timestamps and language selection.2MIT
- AlicenseBqualityDmaintenanceAn MCP server designed to fetch transcripts for YouTube videos. It enables AI tools to access video text content for tasks like summarization, analysis, and key takeaway extraction.173MIT
- FlicenseNot gradedqualityDmaintenanceThis MCP server fetches and extracts transcripts from YouTube videos, enabling AI language models to access and analyze video content.1-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/AndrewCTF/YTT'
If you have feedback or need assistance with the MCP directory API, please join our Discord server