Skip to main content

A CLI tool to download, transcribe, and summarize YouTube videos.

Project description

mdlsum (Media Downloader & Summarizer)

mdlsum is a Python package designed to download, transcribe, and summarize media. Currently, it supports YouTube videos, with plans to expand to podcasts and other media formats. This tool aims to provide basic yet useful summaries, with future iterations planned to enhance its utility for personal and family use.

Features

  • Download YouTube Videos: Fetches the best audio quality available from YouTube videos.
  • Transcribe Audio: Utilizes Whisper to convert audio into text, including timestamps.
  • Summarize Transcriptions: Uses a language model to generate concise summaries formatted as a table of contents with timestamps.

Installation

To install mdlsum-cli, run:

pip install mdlsum-cli

Usage

Set Environment Variable:

Ensure that the OPENAI_API_KEY is set in your environment:

export OPENAI_API_KEY=your_openai_api_key_here

Running the Application

To use the application, simply provide a YouTube URL:

mdlsum "https://www.youtube.com/watch?v=example"

Technical Details

Overview

The mdlsum package combines several powerful tools to achieve its functionality:

  1. yt-dlp: A versatile downloader used to fetch YouTube videos.
  2. ffmpeg: Converts downloaded video audio into the desired format.
  3. whisper.cpp: A lightweight and efficient implementation of OpenAI’s Whisper model, used for transcribing audio.
  4. OpenAI’s GPT-3.5-turbo: Provides the summarization capabilities, transforming transcriptions into concise summaries.
  5. Typer: Facilitates the creation of the command-line interface (CLI).

How it works

Downloading Videos

The process begins with the download.py module, where yt-dlp downloads the audio from a YouTube video. The downloaded audio is then converted to a 16-bit WAV file using ffmpeg. This step ensures that the audio is in a suitable format for transcription.

Transcribing Audio

Next, the transcribe.py module takes over. It uses whisper.cpp to transcribe the audio into text, ensuring that timestamps are included. This transcription process involves the following steps:

  • Checking and downloading the Whisper model if not already present.
  • Running the transcription using the Whisper model to generate a text file with timestamps.

Summarizing Transcriptions

The final step is handled by the summarize.py module. This module sends the transcribed text to OpenAI’s API to generate a summary. The API call includes instructions to format the summary as a table of contents with timestamps. This step ensures that the summary is easy to navigate and understand.

Technologies Used

  • yt-dlp: for downloading YouTube videos and other media
  • ffmpeg: for audio conversion
  • whisper.cpp: for transcription locally on your PC
  • OpenAI API: for summarization
  • Typer: for building the CLI

Building the Project

Development Process

The project was developed incrementally, starting with setting up the basic CLI structure using Typer. Each major feature (downloading, transcribing, summarizing) was implemented and tested separately before being integrated into the final application. The development process involved:

  1. Setting up a virtual environment for dependency management.
  2. Implementing and testing each feature in isolation.
  3. Integrating the features into a cohesive CLI tool.
  4. Packaging the project for distribution.

Acknowledgements

This project wouldn't have been possible without the incredible work of the following individuals and organizations:

  • OpenAI & Anthropic for the Whisper model and their language model APIs
  • Georgi Gerganov for his incredible work on whisper.cpp https://github.com/ggerganov/whisper.cpp
  • yt-dlp https://github.com/yt-dlp/yt-dlp
  • Typer https://github.com/tiangolo/typer

License

See LICENSE.

Future Plans

  • Expand support to include podcasts and other media formats
  • Improve summary quality and customization options
  • Add advanced features like specifying models and timestamps
  • Build a library of podcasts and YouTube video summaries that is searchable

This project is a work in progress, and I look forward to iterating on it to make it even more useful. Thank you for checking it out!

SidRT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdlsum-cli-0.2.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

mdlsum_cli-0.2.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file mdlsum-cli-0.2.0.tar.gz.

File metadata

  • Download URL: mdlsum-cli-0.2.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for mdlsum-cli-0.2.0.tar.gz
Algorithm Hash digest
SHA256 35c7d1df3b85a1999ab55a329cfb945a738d4c2a204980337863236ad44a2a75
MD5 aeb7e1152ce80140b69e723f3937553f
BLAKE2b-256 7fd998bebeffde2b53b845a332ec053a693ea53abad8705f684cc3f64dcc6468

See more details on using hashes here.

File details

Details for the file mdlsum_cli-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mdlsum_cli-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for mdlsum_cli-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13c76d6858c6f98888da170478bcf79ce404ee5e6070bdd6b25da12e12c54c4e
MD5 348f0b5a75485a81db337add594c51ed
BLAKE2b-256 57d5cd51cd51791aae178cc36481d7a9ec9858ba198fc5994b0e47c703c9f994

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page