A Python-based tool for automatically downloading, transcribing, and analyzing YouTube videos or local audio files. It supports both single videos and playlists.
- Downloads YouTube videos and extracts audio
- Processes local audio files (mp3, m4a, wav, mp4, m4v, mov)
- Generates transcripts with speaker labels using AssemblyAI
- Cuts audio into segments based on speaker
- Supports multiple languages (see language codes in the app)
- Concurrent processing for playlists
- Progress tracking and detailed logging
- Clone or download this repository
- Create a Python virtual environment (recommended):
python -m venv .venv
source .venv/bin/activate # On Windows, use: .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- yt-dlp: For downloading YouTube videos
- assemblyai: For transcription and speaker detection
- pydub: Audio processing
- pathvalidate: Path validation
- requests: HTTP client
- instructor: For structured output parsing
- tqdm: Progress bar
- Create a
.envfile in the root directory with your API key:
ASSEMBLYAI_API_KEY=your_assemblyai_api_key
- Create the following directories in the root folder:
mkdir raw_audio transcripts cut_audio logsRun the script:
python main.pyThe script will prompt you for:
- Input type (S/P/L):
- S: Single YouTube video
- P: YouTube playlist
- L: Local audio file
- Language of the audio (type 'help' to see available language codes)
- Video URL or file path
- For playlists: start and end indices (optional)
The script will:
- Download YouTube videos or copy local files
- Extract and save the audio
- Generate transcripts with speaker labels using AssemblyAI
- Cut the audio into segments based on speakers
- Save the results in output.json
The script creates several directories:
raw_audio/: Contains the extracted audio from videostranscripts/: Contains the transcription JSON filescut_audio/: Contains the cut audio segmentslogs/: Contains processing logs with timestamps and progress
- If you get API errors, make sure your AssemblyAI API key in
.envis correct - For audio processing errors, ensure you have ffmpeg installed:
- On Mac:
brew install ffmpeg - On Windows: Download from ffmpeg website
- On Mac:
- If YouTube downloads fail, try updating yt-dlp:
pip install -U yt-dlp
If you need to download age-restricted videos, you may need to provide your YouTube cookies to bypass age restrictions:
- Install a browser extension to export cookies (e.g., "Get cookies.txt" for Chrome)
- Go to YouTube and log in to your account
- Export cookies for youtube.com to a file named
cookies.txt - Place
cookies.txtin the same directory asmain.py
For more details about cookie handling, see the yt-dlp documentation.
After processing, you'll be prompted to delete the contents of the transcripts and cut_audio folders. Choose:
- Y: Delete temporary files
- N: Keep all files