# malomn/dsit architecture

> Architecture diagram of the GitHub repository malomn/dsit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/malomn/dsit
- Repository: https://github.com/malomn/dsit

## Overview

##### Main Components

A. Input Layer:
- Audio Input (.wav files)
- Transcription Input (.lbl/.seg files)

B. Core Processing Components:
- Preprocessing Module (preprocessing.py)
- CNN Model (models/cnn)
- Intelligibility Model (models/intelligibility)
- Severity Model (models/severity)
- ANPS Analysis Module (anps.py)

C. Data Storage:
- Cache System (cache.py)
- Static Data Files (data/*.json)

D. Output Generation:
- JSON Output Generator

##### Component Relationships

**[Input Layer]**
- ↓
**[Preprocessing]**
- ↓
**[Model Processing Layer]**
- → [CNN Model]
- → [Intelligibility Model]
- → [Severity Model]
- ↓
**[Analysis Layer]**
- → [ANPS Analysis]
- → [Confusion Matrix Generation]
- ↓
**[Output Generation]**

##### Important Details

A. Data Flow Annotations:
- Audio signal flow
- Feature extraction paths
- Model inference paths
- Score generation paths

B. Key Components:
- Data storage showing the various JSON configuration files
- Processing pipeline showing the transformation of raw audio to final scores

##### Specific Implementation Notes

- How the cache system interacts with the processing pipeline
- Where the phonetic trait analysis occurs
- Confusion matrix generation process
- Relationship between the various .json data files and the processing components

##### Output Format Details

- Intelligibility scores
- Severity scores
- Confusion matrix
- ANPS scores

- ANPS: Automatic Neuronal Phonetic Score
- CNN: Convolutional Neural Network
- DSIT: Deep Speech Intelligibility Toolkit

This system design should emphasize the pipeline nature of the project while clearly showing how each component contributes to the final speech analysis output.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        style Legend fill:#f0f0f0,stroke:#333,stroke-width:2px
        L1[Input/Output]:::io
        L2[Processing]:::processing
        L3[Models]:::model
        L4[Storage]:::storage
        L5[Analysis]:::analysis
    end

    subgraph "Input Layer"
        AudioIn[Audio Files]:::io
        TransIn[Transcription Files]:::io
        click AudioIn "https://github.com/MaloMn/dsit/tree/main/dsit/audio/"
        click TransIn "https://github.com/MaloMn/dsit/blob/main/examples/alignment.lbl"
    end

    subgraph "Processing Layer"
        Preproc[Preprocessing Module]:::processing
        Utils[Utility Functions]:::processing
        click Preproc "https://github.com/MaloMn/dsit/blob/main/dsit/preprocessing.py"
        click Utils "https://github.com/MaloMn/dsit/blob/main/dsit/utils.py"
    end

    subgraph "Model Layer"
        ModelHandler[Model Handler]:::processing
        CNNModel[CNN Model]:::model
        IntModel[Intelligibility Model]:::model
        SevModel[Severity Model]:::model
        click ModelHandler "https://github.com/MaloMn/dsit/blob/main/dsit/model.py"
        click CNNModel "https://github.com/MaloMn/dsit/tree/main/dsit/models/cnn/"
        click IntModel "https://github.com/MaloMn/dsit/tree/main/dsit/models/intelligibility/"
        click SevModel "https://github.com/MaloMn/dsit/tree/main/dsit/models/severity/"
    end

    subgraph "Analysis Layer"
        ANPS[ANPS Analysis]:::analysis
        IntProc[Intelligibility Processing]:::analysis
        ConfMatrix[Confusion Matrix]:::analysis
        click ANPS "https://github.com/MaloMn/dsit/blob/main/dsit/anps.py"
        click IntProc "https://github.com/MaloMn/dsit/blob/main/dsit/intelligibility.py"
    end

    subgraph "Storage Layer"
        Cache[Cache System]:::storage
        PhoneticData[Phonetic Data]:::storage
        NeuronData[Neuron Data]:::storage
        PhoneMap[Phoneme Mapping]:::storage
        NormData[Normalization Data]:::storage
        click Cache "https://github.com/MaloMn/dsit/blob/main/dsit/cache.py"
        click PhoneticData "https://github.com/MaloMn/dsit/blob/main/dsit/data/phonetic_traits.json"
        click NeuronData "https://github.com/MaloMn/dsit/blob/main/dsit/data/dead_neurons.json"
        click PhoneMap "https://github.com/MaloMn/dsit/blob/main/dsit/data/numeric_phones.json"
        click NormData "https://github.com/MaloMn/dsit/blob/main/dsit/data/normalization_factors.json"
    end

    subgraph "Output Layer"
        OutputJSON[JSON Output]:::io
        click OutputJSON "https://github.com/MaloMn/dsit/blob/main/examples/example.json"
    end

    AudioIn & TransIn --> Preproc
    Preproc --> ModelHandler
    Utils --> ModelHandler
    ModelHandler --> CNNModel & IntModel & SevModel
    CNNModel & IntModel & SevModel --> ANPS
    CNNModel & IntModel & SevModel --> IntProc
    IntProc --> ConfMatrix
    ANPS & ConfMatrix --> OutputJSON
    
    Cache -.-> ModelHandler
    PhoneticData & NeuronData & PhoneMap & NormData -.-> ModelHandler

    classDef io fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef processing fill:#90EE90,stroke:#333,stroke-width:2px
    classDef model fill:#FFD700,stroke:#333,stroke-width:2px
    classDef storage fill:#FFA500,stroke:#333,stroke-width:2px
    classDef analysis fill:#DDA0DD,stroke:#333,stroke-width:2px
```
