Subtitles first: First grab official/automatic subtitles (second-level, no GPU needed); if unavailable, download the audio and transcribe with SenseVoice-Small; English content is automatically translated into Chinese, with bilingual Chinese-English Markdown output. Add --no-subtitle to force audio transcription.
Why you need this
YouTube has a wealth of high-quality English content, but many people don't have time to watch it all or don't understand the language. This skill:
- Transcribes videos into text (supports Chinese and English)
- Automatically translates English content into high-quality Chinese
- Outputs bilingual Chinese-English text for easy learning
Environment Requirements
# Python 3.9+
python -m venv .venv
source .venv/bin/activate
Dependencies
pip install funasr modelscope torch torchaudio
System Dependencies macOS: brew install ffmpeg yt-dlp Ubuntu: sudo apt install ffmpeg && pip install yt-dlp Translation Feature (optional, required for English videos)export DEEPSEEK_API_KEY="your-api-key"
## 使用方法
```bash
python scripts/transcribe.py "https://www.youtube.com/watch?v=xxxxx"
python scripts/transcribe.py "https://www.youtube.com/watch?v=xxxxx" --output ./output
python scripts/transcribe.py "https://www.youtube.com/watch?v=xxxxx" --no-translate # 不翻译
python scripts/transcribe.py "https://www.youtube.com/watch?v=xxxxx" --no-subtitle # 强制音频转录
python scripts/batch_transcribe.py urls.txt -o ./output --no-translate
Workflow
Step 1: yt-dlp downloads audio
yt-dlp --extract-audio --audio-format mp3 --audio-quality 128K \
"https://www.youtube.com/watch?v=xxxxx"
Step 2: SenseVoice-Small transcription
from funasr import AutoModel
model = AutoModel(model="iic/SenseVoiceSmall", ...)
result = model.generate(input=audio_path, language="auto", use_itn=True)
Step 3: Language detection + translation
- Chinese content → output directly
- English content → LLM translates into Chinese, outputs bilingual Chinese-English text
Step 4: Generate Markdown
---
title: 视频标题
type: note
tags: [YouTube]
language: en
translated: true
---
# 视频标题
> 转录引擎:SenseVoice-Small | 翻译:DeepSeek
## 中文翻译
翻译内容...
---
## English Original
原文内容...
Batch Mode
scripts/batch_transcribe.py Supports batch processing of a URL list; by default, if one item fails it continues processing the next; to enable strict mode, add --stop-on-error。
Translation Configuration
By default, uses the DeepSeek API for translation. You need to set the environment variable:
export DEEPSEEK_API_KEY="your-api-key"
Supported LLMs:
- DeepSeek (recommended, high cost-effectiveness)
- OpenAI
- Any service compatible with the OpenAI API format
Performance Data
| Video Duration | Download | Transcription | Translation | Total Time |
|---|---|---|---|---|
| 5 min | ~10s | ~5s | ~10s | ~30s |
| 10 min | ~15s | ~10s | ~20s | ~50s |
| 30 min | ~30s | ~30s | ~60s | ~2min |
Known Limitations
- SenseVoice-Small's English transcription accuracy is not as good as its Chinese
- Translation quality depends on LLM capability
- Translating long videos may take a relatively long time
- Some YouTube videos have regional restrictions
Reference Projects
- yt-dlp/yt-dlp - Video download tool
- FunAudioLLM/SenseVoice - Speech recognition model
- DeepSeek - LLM for translation
⚖️ Compliance Statement
Forpersonal learning and researchuse only. Please comply with the target platform's Terms of Service (ToS) and robots rules, control request frequency, and do not use it for bulk scraping, commercial crawling, or scenarios that infringe on others' rights. The copyright of downloaded content belongs to the original author.