# clement-pages/gryannote architecture

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

- Interactive diagram: https://gitdiagram.com/clement-pages/gryannote
- Repository: https://github.com/clement-pages/gryannote

## Overview

Based on our analysis, this project is an open-source tool providing a set of custom Gradio components specifically designed for speaker diarization labeling. Its purpose is to integrate with the pyannote ecosystem, allowing users to load pretrained pipelines, upload or record audio, process it, interactively label speaker segments, and output RTTM files. The project is structured into several clearly separated modules (audio, pipeline, and rttm), each with its own frontend and backend components.

##### Main Components
- Core Labeling Components: There are three main domains:
- gryannote_audio: Contains the logic for audio labeling, including both backend processing (e.g., audio_labeling.py, core.py) and interactive frontend components (Svelte files such as Example.svelte, Index.svelte, and specialized modules like recorder, player, and interactive).
- gryannote_pipeline: Manages the pipeline selection and integration with pyannote pipelines. It similarly has backend components (pipelineselector.py) and dedicated frontend elements (e.g., Example.svelte, Index.svelte, shared UI components like Dropdown and Multiselect).
- gryannote_rttm: Focuses on processing or generating RTTM outputs from the diarization results. It also splits into backend (rttm.py) and frontend modules (using Gradio/JavaScript elements such as gradio.config.js and Svelte components for file handling).
- Demo Applications: Located in separate demo directories under each module, these illustrate the component usage by instantiating end-to-end interfaces.
- Configuration and CI/CD: Files such as pyproject.toml, GitHub workflows, and pre-commit configurations provide the build, dependency, and integration details but aren't part of the runtime architecture—they support development and deployment.

##### Relationships and Interactions
- Underlying dependency on pyannote (a separate external API/component) which provides the speaker diarization pipeline that all modules rely on.

##### Architectural Patterns and Design Principles
- Separation of concerns: Each module (audio, pipeline, rttm) is self-contained with its own backend and frontend.
- Component-based architecture: The use of Gradio custom components and Svelte for UI encourages reusability and independent testing.
- Layered approach: Presentation (frontend UI in Svelte/Gradio) is separated from the application logic (Python backend) and configuration/deployment layers.

##### Technologies and Frameworks Highlight
- Python is used for the backend components (scripts and package management via pyproject.toml).
- Gradio provides the interface integration, as noted in the README.
- Svelte is the framework of choice for the frontend components.
- Integration with pyannote: The externally maintained speaker diarization pipeline.
- Continuous integration and deployment files (GitHub workflows) denote robust DevOps practices.

- Core functionality: How each labeling component deals with input, processing, interaction, and output.
- Extensibility: Indicate that each component (audio, pipeline, rttm) is independently usable.
- Integration points: Identify where external dependencies, such as pyannote pipelines, play a role.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global User Interaction
    User["User (Uploads/RecordsAudio)"]:::external
    User -->|"initiates"| A1
    User -->|"initiates"| P1
    User -->|"initiates"| R1

    %% Audio Labeling Domain
    subgraph "Audio Labeling Domain"
        A1["Audio Frontend (Svelte)"]:::frontend
        A2["Audio Backend (Python)"]:::backend
        Audio_Shared["Shared Utils (Audio Frontend)"]:::shared
        A3["Audio Demo Application"]:::demo

        A1 -->|"sendsInput"| A2
        A2 -->|"returnsResults"| A1
        A1 -->|"uses"| Audio_Shared
        A2 -->|"integrates"| A3
    end

    %% Pipeline Selector Domain
    subgraph "Pipeline Selector Domain"
        P1["Pipeline Frontend (Svelte)"]:::frontend
        P2["Pipeline Backend (Python)"]:::backend
        Pipeline_Shared["Shared Utils (Pipeline Frontend)"]:::shared
        P3["Pipeline Demo Application"]:::demo
        External["pyannote Pipeline"]:::external

        P1 -->|"sendsSelection"| P2
        P2 -->|"returnsPipeline"| P1
        P1 -->|"uses"| Pipeline_Shared
        P2 -->|"integrates"| P3
        External -->|"supplies"| P2
    end

    %% RTTM Generation Domain
    subgraph "RTTM Generation Domain"
        R1["RTTM Frontend (Gradio/Svelte)"]:::frontend
        R2["RTTM Backend (Python)"]:::backend
        RTTM_Shared["Shared Utils (RTTM Frontend)"]:::shared
        R3["RTTM Demo Application"]:::demo

        R1 -->|"sendsOutputRequest"| R2
        R2 -->|"generatesRTTM"| R1
        R1 -->|"uses"| RTTM_Shared
        R2 -->|"integrates"| R3
    end

    %% Configuration and CI/CD Support
    Conf["Configuration & CI/CD (pyproject.toml, GitHubWorkflows, Pre-commit)"]:::config

    A3 -->|"configuredBy"| Conf
    P3 -->|"configuredBy"| Conf
    R3 -->|"configuredBy"| Conf

    %% Click Events
    click A2 "https://github.com/clement-pages/gryannote/tree/main/gryannote/audio/backend/gryannote_audio"
    click A1 "https://github.com/clement-pages/gryannote/tree/main/gryannote/audio/frontend"
    click A3 "https://github.com/clement-pages/gryannote/blob/main/gryannote/audio/demo/app.py"

    click P2 "https://github.com/clement-pages/gryannote/tree/main/gryannote/pipeline/backend/gryannote_pipeline"
    click P1 "https://github.com/clement-pages/gryannote/tree/main/gryannote/pipeline/frontend"
    click P3 "https://github.com/clement-pages/gryannote/blob/main/gryannote/pipeline/demo/app.py"

    click R2 "https://github.com/clement-pages/gryannote/tree/main/gryannote/rttm/backend/gryannote_rttm"
    click R1 "https://github.com/clement-pages/gryannote/tree/main/gryannote/rttm/frontend"
    click R3 "https://github.com/clement-pages/gryannote/blob/main/gryannote/rttm/demo/app.py"

    click Audio_Shared "https://github.com/clement-pages/gryannote/tree/main/gryannote/audio/frontend/shared"
    click Pipeline_Shared "https://github.com/clement-pages/gryannote/tree/main/gryannote/pipeline/frontend/shared"
    click RTTM_Shared "https://github.com/clement-pages/gryannote/tree/main/gryannote/rttm/frontend/shared"

    click Conf "https://github.com/clement-pages/gryannote/blob/main/.github"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#FFDAB9,stroke:#333,stroke-width:2px;
    classDef demo fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef shared fill:#E6E6FA,stroke:#333,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef config fill:#FFFACD,stroke:#333,stroke-width:2px;
```
