# tsmdt/whisply architecture

> Architecture diagram of the GitHub repository tsmdt/whisply, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tsmdt/whisply
- Repository: https://github.com/tsmdt/whisply

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Processing Pipeline:
- Input Handler (handles files, folders, URLs, and .list files)
- Transcription Engine (manages different Whisper implementations)
- Speaker Annotation System (WhisperX integration)
- Post-processing Module (corrections and enhancements)
- Output Generator (multiple format support)

b) Integration Components:
- FFmpeg Integration
- HuggingFace Integration
- Device Management System

**[Input Sources] → [Input Handler] → [Device Manager] → [Processing Pipeline] → [Output Generator] → [Export Formats]**

##### Specific Implementation Details

- The automatic device selection logic
- The parallel processing capabilities
- The integration points with external services
- The configuration management system
- The post-processing pipeline

##### Component Relationships

Key relationships:
- How the CLI (cli.py) and App (app.py) interface with the core system
- The interaction between diarize_utils.py and the speaker annotation system
- How enhance_annotations.py fits into the processing pipeline
- The role of post_correction.py in the output generation

##### Technical Details

Annotations for:
- Supported Whisper models
- Hardware requirements for each processing mode
- File format support
- Configuration options

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Core Components]:::core
        L2[External Integrations]:::external
        L3[Input/Output]:::io
        L4[Device Management]:::device
        L5[Optional Flow]:::optional
    end

    subgraph "Input Layer"
        Files[Files]:::io
        Folders[Folders]:::io
        URLs[URLs]:::io
        ListFiles[".list files"]:::io
        InputHandler["Input Handler"]:::io
        FFmpeg["FFmpeg Integration"]:::external
        
        Files & Folders & URLs & ListFiles --> InputHandler
        InputHandler --> FFmpeg
    end

    subgraph "Device Management"
        DeviceManager["Device Manager"]:::device
        CPU["CPU\n(faster-whisper)"]:::device
        GPU["GPU\n(NVIDIA)"]:::device
        MPS["MPS\n(Apple Silicon)"]:::device
        
        DeviceManager --> CPU & GPU & MPS
    end

    subgraph "Processing Pipeline"
        TranscriptionEngine["Transcription Engine"]:::core
        TranslationModule["Translation Module"]:::optional
        SpeakerAnnotation["Speaker Annotation"]:::core
        PostProcessing["Post-processing"]:::core
        HuggingFace["HuggingFace Integration"]:::external
        Enhancement["Enhancement Module"]:::core
        
        TranscriptionEngine --> TranslationModule
        TranscriptionEngine --> SpeakerAnnotation
        SpeakerAnnotation --> HuggingFace
        SpeakerAnnotation --> PostProcessing
        PostProcessing --> Enhancement
    end

    subgraph "Output Layer"
        OutputGen["Output Generator"]:::io
        JSON[".json"]:::io
        TXT[".txt"]:::io
        SRT[".srt"]:::io
        WEBVTT[".webvtt"]:::io
        RTTM[".rttm"]:::io
        
        OutputGen --> JSON & TXT & SRT & WEBVTT & RTTM
    end

    FFmpeg --> DeviceManager
    DeviceManager --> TranscriptionEngine
    Enhancement --> OutputGen

    %% Interface Components
    CLI["Command Line Interface"]:::core
    APP["Application Interface"]:::core
    CONFIG["Configuration"]:::core

    CLI & APP --> InputHandler
    CONFIG --> TranscriptionEngine
    CONFIG --> PostProcessing

    %% Styling
    classDef core fill:#a8d1f0,stroke:#333
    classDef external fill:#90EE90,stroke:#333
    classDef io fill:#FFB347,stroke:#333
    classDef device fill:#D3D3D3,stroke:#333
    classDef optional fill:#fff,stroke:#333,stroke-dasharray: 5 5

    %% Click Events
    click TranscriptionEngine "https://github.com/tsmdt/whisply/blob/main/whisply/transcription.py"
    click SpeakerAnnotation "https://github.com/tsmdt/whisply/blob/main/whisply/diarize_utils.py"
    click PostProcessing "https://github.com/tsmdt/whisply/blob/main/whisply/post_correction.py"
    click OutputGen "https://github.com/tsmdt/whisply/blob/main/whisply/output_utils.py"
    click InputHandler "https://github.com/tsmdt/whisply/blob/main/whisply/download_utils.py"
    click Enhancement "https://github.com/tsmdt/whisply/blob/main/whisply/enhance_annotations.py"
    click DeviceManager "https://github.com/tsmdt/whisply/blob/main/whisply/models.py"
    click APP "https://github.com/tsmdt/whisply/blob/main/whisply/app.py"
    click CLI "https://github.com/tsmdt/whisply/blob/main/whisply/cli.py"
    click CONFIG "https://github.com/tsmdt/whisply/blob/main/examples/example_config.json"
```
