Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

2 watching

Forks

Repository files navigation

Youtube-Autolabel

A Python-based tool for automatically downloading, transcribing, and analyzing YouTube videos or local audio files. It supports both single videos and playlists.

Features

  • 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

Installation

  1. Clone or download this repository
  2. Create a Python virtual environment (recommended):
python -m venv .venv
source .venv/bin/activate  # On Windows, use: .venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Required Dependencies

  • 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

Environment Setup

  1. Create a .env file in the root directory with your API key:
ASSEMBLYAI_API_KEY=your_assemblyai_api_key
  1. Create the following directories in the root folder:
mkdir raw_audio transcripts cut_audio logs

Usage

Run the script:

python main.py

The script will prompt you for:

  1. Input type (S/P/L):
    • S: Single YouTube video
    • P: YouTube playlist
    • L: Local audio file
  2. Language of the audio (type 'help' to see available language codes)
  3. Video URL or file path
  4. 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

Output

The script creates several directories:

  • raw_audio/: Contains the extracted audio from videos
  • transcripts/: Contains the transcription JSON files
  • cut_audio/: Contains the cut audio segments
  • logs/: Contains processing logs with timestamps and progress

Troubleshooting

  1. If you get API errors, make sure your AssemblyAI API key in .env is correct
  2. For audio processing errors, ensure you have ffmpeg installed:
    • On Mac: brew install ffmpeg
    • On Windows: Download from ffmpeg website
  3. If YouTube downloads fail, try updating yt-dlp: pip install -U yt-dlp

Handling Age-Restricted Videos

If you need to download age-restricted videos, you may need to provide your YouTube cookies to bypass age restrictions:

  1. Install a browser extension to export cookies (e.g., "Get cookies.txt" for Chrome)
  2. Go to YouTube and log in to your account
  3. Export cookies for youtube.com to a file named cookies.txt
  4. Place cookies.txt in the same directory as main.py

For more details about cookie handling, see the yt-dlp documentation.

Cleanup

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

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages