A CLI tool to transcribe, summarize and translate YouTube videos
Project description
ytbrf (YouTube Brief)
A CLI tool that takes a YouTube video link and generates a summary of the video content. The tool can also translate the summary into different languages.
Features
- Automatic transcript extraction from YouTube (if available)
- Local audio transcription using Whisper when YouTube transcript is not available
- AI-powered text summarization
- Optional translation of summaries
- Progress bars and rich console output
- Support for multiple languages
- Flexible configuration system
Prerequisites
- Python 3.8 or higher
- FFmpeg (for audio processing)
- YouTube API key (for accessing YouTube transcripts)
Installation
- Clone the repository:
git clone https://github.com/yourusername/ytbrf.git
cd ytbrf
- Install the package:
pip install -e .
- Set up your YouTube API key:
export YOUTUBE_API_KEY='your_api_key_here'
Configuration
ytbrf uses a YAML configuration file to customize its behavior. The configuration file can be placed in:
- Current directory (
config.yaml) - User's config directory (
~/.config/ytbrf/config.yaml)
Configuration Options
# Summary settings
summary:
# Relative length of the summary (0.0 to 1.0)
ratio: 0.2
# Target language for translation (ISO 639-1 code, e.g., 'en', 'es', 'fr')
target_language: ""
# Transcription settings
transcription:
# Path to whisper.cpp executable
whisper_path: "whisper"
# Whisper model to use (tiny, base, small, medium, large)
model: "base"
# Language to force for transcription (empty for auto-detect)
force_language: ""
# Output settings
output:
# Default output directory
directory: "."
# File naming pattern (available variables: {title}, {id}, {lang})
filename_pattern: "{title}-{lang}.txt"
# YouTube settings
youtube:
# YouTube API key (required for transcript download)
api_key: ""
# Preferred audio quality (best, worst, or specific quality like 192k)
audio_quality: "best"
# Audio format (mp3, m4a, etc.)
audio_format: "mp3"
# Translation settings
translation:
# Translation model to use
model: "Helsinki-NLP/opus-mt-{src}-{tgt}"
# Whether to translate the full transcript (true) or just the summary (false)
translate_full: false
Default Values
If no configuration file is found, ytbrf will use these default values:
- Summary ratio: 20% of original length
- Whisper model: "base"
- Output directory: current directory
- Audio format: mp3
- Translation: disabled by default
Usage
Basic usage:
ytbrf "https://www.youtube.com/watch?v=VIDEO_ID"
With custom summary ratio (e.g., 30% of original length):
ytbrf "https://www.youtube.com/watch?v=VIDEO_ID" --ratio 0.3
With translation to English:
ytbrf "https://www.youtube.com/watch?v=VIDEO_ID" --translate en
With custom output directory:
ytbrf "https://www.youtube.com/watch?v=VIDEO_ID" --output-dir ./summaries
Output Files
For a video titled "Example Video", the tool will generate:
Example Video.txt- Full transcriptExample Video-summary-{original_language}.txt- Summary in original languageExample Video-summary-{target_language}.txt- Translated summary (if translation requested)
How It Works
- The tool first attempts to get the transcript directly from YouTube using the YouTube API
- If no transcript is available, it downloads the audio and uses Whisper for local transcription
- The transcript is then summarized using a transformer model
- If translation is requested, the summary is translated to the target language
- All files are saved in the specified output directory
Supported Languages
The tool supports translation to any language available in the Helsinki-NLP models. Common language codes include:
en- Englishes- Spanishfr- Frenchde- Germanit- Italianpt- Portugueseru- Russianzh- Chineseja- Japaneseko- Korean
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ytbrf-0.0.1-py3-none-any.whl.
File metadata
- Download URL: ytbrf-0.0.1-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f5253761cc4c56f4c79b3a4b67b54fa973970d998f3d97f5fc2b89e8897285c
|
|
| MD5 |
b9aee617d4bf529caef7543a8f487580
|
|
| BLAKE2b-256 |
c98fdecc57eaf91836ad22dc735611e44b892650694dd577e6972d2b5323b984
|