Skip to main content

A Python package to generate AI-powered transcripts from YouTube videos

Project description

README.md

YouTube Transcript Generator

A powerful, AI-enhanced YouTube transcript generator using Gemini Pro. Generate high-quality transcripts with advanced features like speaker detection, multi-language support, and custom formatting.

Features

  • 🎯 High-accuracy transcription using AI enhancement
  • 🌍 Multi-language support with translation capabilities
  • 👥 Speaker detection and labeling
  • ⏱️ Timestamp preservation and formatting
  • 🎨 Custom output formats (TXT, SRT, VTT, JSON, MD)
  • 🚀 Async processing for better performance
  • 📊 Quality metrics and confidence scoring
  • 💾 Caching support for better efficiency
  • 🛡️ Comprehensive error handling
  • 📝 Detailed logging system

Installation

pip install youtube-transcript-generator

Quick Start

from youtube_transcript_generator import TranscriptGenerator

async def main():
    generator = TranscriptGenerator()
    result = await generator.generate_transcript(
        "https://youtube.com/watch?v=your_video_id",
        options=TranscriptionOptions(
            target_language="en",
            enhance_formatting=True
        )
    )
    print(result.transcript)

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

CLI Usage (COMING SOON)

# Generate transcript
yt-transcript generate https://youtube.com/watch?v=your_video_id -o transcript.txt

# With options
yt-transcript generate https://youtube.com/watch?v=your_video_id \
    --language es \
    --format srt \
    --timestamps \
    --speakers

Configuration

Create a .env file:

GEMINI_API_KEY=your_gemini_api_key
YOUTUBE_API_KEY=your_youtube_api_key  # Optional
DEBUG=False
LOG_LEVEL=INFO

Documentation

Visit our documentation for detailed information.

Contributing

We welcome contributions! Please see our contributing guidelines.

License

MIT License - see LICENSE for details.

API.md

API Documentation

Core Components

TranscriptGenerator

The main class for generating transcripts.

class TranscriptGenerator:
    async def generate_transcript(
        video_url: str,
        options: Optional[TranscriptionOptions] = None
    ) -> TranscriptionResult:
        """Generate transcript for a YouTube video."""

TranscriptionOptions

Configure transcript generation:

class TranscriptionOptions(BaseModel):
    target_language: Optional[str] = None
    enhance_formatting: bool = True
    include_timestamps: bool = False
    detect_speakers: bool = False
    custom_formatting: Optional[dict] = None

VideoInfo

Video information model:

class VideoInfo(BaseModel):
    video_id: str
    title: str
    duration: int
    language: Optional[str]
    captions_available: bool
    url: str
    author: str
    view_count: Optional[int]
    metadata: dict

Error Handling (Exception Classes)

The library defines several exception classes:

  • TranscriptionError: Base exception
  • ValidationError: Input validation errors
  • VideoProcessingError: Video processing failures
  • AIProcessingError: AI processing issues

Examples

Basic Usage

from youtube_transcript_generator import TranscriptGenerator

generator = TranscriptGenerator()
result = await generator.generate_transcript("https://youtube.com/watch?v=...")
print(result.transcript)

Advanced Usage

options = TranscriptionOptions(
    target_language="es",
    enhance_formatting=True,
    include_timestamps=True,
    detect_speakers=True,
    custom_formatting={"format": "srt"}
)

result = await generator.generate_transcript(
    "https://youtube.com/watch?v=...",
    options=options
)

Enhanced Usage

As a module

runner = TranscriptRunner()
output_files = await runner.process_video(
    "https://youtube.com/watch?v=VIDEO_ID",
    {
        'save_json': True,
        'save_srt': True,
        'save_vtt': True,
        'save_txt': True,
        'include_timestamps': True
    }
)

As command line tool (Need to Build the package locally)

python runner.py "https://youtube.com/watch?v=VIDEO_ID" \
    --formats json,srt,vtt,txt \
    --timestamps \
    --output-dir my_transcripts

CONTRIBUTING.md

Contributing Guidelines

Getting Started

  1. Fork the repository
  2. Clone your fork
  3. Create a virtual environment
  4. Install development dependencies
pip install -e ".[dev]"

Development Process

  1. Create a new branch
  2. Make your changes
  3. Write/update tests
  4. Update documentation
  5. Submit a pull request

Code Style

  • Follow PEP 8
  • Use type hints
  • Write docstrings (Google style)
  • Keep functions focused and small
  • Add comments for complex logic

Testing (COMING SOON)

Run tests:

pytest

With coverage:

pytest --cov=youtube_transcript_generator

Documentation

  • Update API documentation for new features
  • Add examples for new functionality
  • Keep README.md up to date

Pull Request Process

  1. Update CHANGELOG.md
  2. Ensure tests pass
  3. Update documentation
  4. Wait for review

architecture.md

Architecture Overview

Core Components

TranscriptGenerator

The main orchestrator that:

  • Coordinates video processing
  • Manages AI enhancement
  • Handles output formatting

YouTubeClient

Responsible for:

  • Video information retrieval
  • Caption downloading
  • Format conversion

AI Processor

Handles:

  • Transcript enhancement
  • Language processing
  • Quality validation

Data Flow

  1. User Input → Video URL
  2. URL → Video Information
  3. Video → Raw Captions
  4. Captions → AI Processing
  5. AI Output → Final Transcript

Design Principles

  1. Modularity

    • Separate concerns
    • Pluggable components
    • Easy extensions
  2. Robustness

    • Error handling
    • Retry logic
    • Validation
  3. Performance

    • Async operations
    • Caching
    • Rate limiting
  4. Maintainability

    • Clear structure
    • Documentation
    • Type safety

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

youtube_transcript_generator-0.1.1.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

youtube_transcript_generator-0.1.1-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file youtube_transcript_generator-0.1.1.tar.gz.

File metadata

File hashes

Hashes for youtube_transcript_generator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5444f56ec932a7afc5c4a814081125af024d1308f29e3c9ceec56d27a588abc2
MD5 b1b5edd802aa7a5df8f3cea30737a1b4
BLAKE2b-256 01b15c0ead1b332e818fa2d46cf0cfcac68cf9e997b33989c3be4f05ff293641

See more details on using hashes here.

File details

Details for the file youtube_transcript_generator-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for youtube_transcript_generator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 edb02e8182b5412e9dff25253d7862795da691a3d30148880cd1cf1a47ec84ce
MD5 a88e750f4174c9134fb749fe8f9c9df9
BLAKE2b-256 d7c0d44742760ac639e4096d03488199c04e784a5de526c02ad74aac77eb36dd

See more details on using hashes here.

Supported by

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