A Python script that automatically downloads YouTube videos and generates text transcriptions using OpenAI's Whisper model.
- Downloads audio from YouTube videos using yt-dlp
- Transcribes audio using OpenAI's Whisper model
- Saves transcriptions as formatted text files
- Handles temporary file management
- Supports various audio formats through FFmpeg
- Processes transcriptions into readable sentences
Before running this script, make sure you have the following installed:
pip install -r requirements.txt
Required packages:
- yt-dlp
- whisper
- librosa
- ffmpeg (system dependency)
- Clone this repository:
git clone https://github.com/Khalid1G/Whisper-YouTube-Transcription.git
cd Whisper-YouTube-Transcription
- Install the required packages:
pip install -r requirements.txt
- Install FFmpeg (if not already installed):
- On Ubuntu/Debian:
sudo apt-get install ffmpeg
- On macOS:
brew install ffmpeg
- On Windows: Download from FFmpeg official website
- Run the script:
python transcriber.py
-
Enter the YouTube video ID when prompted. The video ID is the part after
v=
in the YouTube URL. For example, forhttps://www.youtube.com/watch?v=dQw4w9WgXcQ
, the ID isdQw4w9WgXcQ
-
The script will:
- Download the audio from the YouTube video
- Process the audio using Whisper
- Save the transcription to
Youtube/[video_id]_transcription.txt
The transcription will be saved in the Youtube
directory with the filename pattern:
[video_id]_transcription.txt
The output text is formatted with one sentence per line for better readability.
.
├── transcriber.py # Main script
├── yt_transcription.ipynb # Notebook script
├── requirements.txt # Python dependencies
├── Youtube/ # Directory for transcription outputs
└── README.md # This file
- Transcription time varies based on:
- Video length
- Computer specifications
- Chosen Whisper model ("base" in this implementation)
- Requires stable internet connection for YouTube downloads
- Processing time depends on video length and hardware capabilities
- Accuracy depends on audio quality and Whisper model used
Feel free to open issues or submit pull requests with improvements.