# matluch/klovia-ai architecture

> Architecture diagram of the GitHub repository matluch/klovia-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/matluch/klovia-ai
- Repository: https://github.com/matluch/klovia-ai
- Video tour (about a minute): https://gitdiagram.com/matluch/klovia-ai/video

## Overview

Klovia’s main workflow listens to microphone speech, sends it to Google for transcription, classifies the text locally, extracts any numeric volume amount, and dispatches recognized commands to media or volume controls. A separate training path builds the classifier from phrase examples. The graph preserves the documented training/model relationship, but its exact artifact handoff is uncertain: the training script saves under the user’s Documents directory while the runtime loads the model from the repository. Edges reflect the shown entry-point calls or documented behavior; unsampled internals are not inferred.

Main entry points: [`Main.py`](https://github.com/matluch/klovia-ai/blob/main/Main.py) (Voice Loop), [`Media_And_Volume/MediaControls.py`](https://github.com/matluch/klovia-ai/blob/main/Media_And_Volume/MediaControls.py) (Media Commands), [`AI_Training/TrainModel1.py`](https://github.com/matluch/klovia-ai/blob/main/AI_Training/TrainModel1.py) (Model Trainer), [`AI_Training/Run1.py`](https://github.com/matluch/klovia-ai/blob/main/AI_Training/Run1.py) (Intent Classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Voice Runtime"]
  node_main["Voice Loop<br/>[Main.py]"]
end

subgraph group_intent["Command Interpretation"]
  node_classifier["Intent Classifier<br/>[Run1.py]"]
  node_number["Number Locator<br/>[numberLocator.py]"]
end

subgraph group_training["Model Training"]
  node_trainer["Model Trainer<br/>[TrainModel1.py]"]
  node_phrases["Training Phrases"]
  node_model["Trained Model<br/>[music_model.pth]"]
end

subgraph group_controls["System Controls"]
  node_media["Media Commands<br/>[MediaControls.py]"]
  node_volume["Volume Commands<br/>[Volume.py]"]
end

node_user(("Speaker"))
node_google["Google Speech"]
node_mediaapps["Media Apps"]
node_audio["Windows Audio"]

node_user -->|"speaks to"| node_main
node_main -->|"transcribes via"| node_google
node_main -->|"classifies with"| node_classifier
node_main -->|"extracts number"| node_number
node_main -->|"dispatches commands"| node_media
node_main -->|"dispatches commands"| node_volume
node_trainer -->|"loads examples"| node_phrases
node_trainer -.->|"produces model"| node_model
node_classifier -->|"loads weights"| node_model
node_media -->|"sends media keys"| node_mediaapps
node_volume -->|"sets volume"| node_audio
node_media -->|"mutes audio"| node_audio

click node_main "https://github.com/matluch/klovia-ai/blob/main/Main.py"
click node_classifier "https://github.com/matluch/klovia-ai/blob/main/AI_Training/Run1.py"
click node_number "https://github.com/matluch/klovia-ai/blob/main/Tools/numberLocator.py"
click node_trainer "https://github.com/matluch/klovia-ai/blob/main/AI_Training/TrainModel1.py"
click node_phrases "https://github.com/matluch/klovia-ai/blob/main/AI_Training/TrainingDataTest.json"
click node_model "https://github.com/matluch/klovia-ai/blob/main/AI_Training/music_model.pth"
click node_media "https://github.com/matluch/klovia-ai/blob/main/Media_And_Volume/MediaControls.py"
click node_volume "https://github.com/matluch/klovia-ai/blob/main/Media_And_Volume/Volume.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main toneBlue
class node_classifier,node_number toneAmber
class node_trainer,node_phrases,node_model toneMint
class node_media,node_volume toneRose
class node_user,node_google,node_mediaapps,node_audio toneIndigo
```

## Components

### Voice Runtime

- [Voice Loop](https://github.com/matluch/klovia-ai/blob/main/Main.py): `Main.py`

### Command Interpretation

- [Intent Classifier](https://github.com/matluch/klovia-ai/blob/main/AI_Training/Run1.py): `AI_Training/Run1.py`
- [Number Locator](https://github.com/matluch/klovia-ai/blob/main/Tools/numberLocator.py): `Tools/numberLocator.py`

### Model Training

- [Model Trainer](https://github.com/matluch/klovia-ai/blob/main/AI_Training/TrainModel1.py): `AI_Training/TrainModel1.py`
- [Training Phrases](https://github.com/matluch/klovia-ai/blob/main/AI_Training/TrainingDataTest.json): `AI_Training/TrainingDataTest.json`
- [Trained Model](https://github.com/matluch/klovia-ai/blob/main/AI_Training/music_model.pth): `AI_Training/music_model.pth`

### System Controls

- [Media Commands](https://github.com/matluch/klovia-ai/blob/main/Media_And_Volume/MediaControls.py): `Media_And_Volume/MediaControls.py`
- [Volume Commands](https://github.com/matluch/klovia-ai/blob/main/Media_And_Volume/Volume.py): `Media_And_Volume/Volume.py`

### Other components

- **Speaker**
- **Google Speech**
- **Media Apps**
- **Windows Audio**

## Connections

- Speaker → Voice Loop: speaks to (evidence: `README.md`)
- Voice Loop → Google Speech: transcribes via (evidence: `Main.py`)
- Voice Loop → Intent Classifier: classifies with (evidence: `Main.py`)
- Voice Loop → Number Locator: extracts number (evidence: `Main.py`)
- Voice Loop → Media Commands: dispatches commands (evidence: `Main.py`)
- Voice Loop → Volume Commands: dispatches commands (evidence: `Main.py`)
- Model Trainer → Training Phrases: loads examples (evidence: `AI_Training/TrainModel1.py`)
- Model Trainer → Trained Model: produces model
- Intent Classifier → Trained Model: loads weights (evidence: `AI_Training/Run1.py`)
- Media Commands → Media Apps: sends media keys (evidence: `Media_And_Volume/MediaControls.py`)
- Volume Commands → Windows Audio: sets volume (evidence: `Media_And_Volume/Volume.py`)
- Media Commands → Windows Audio: mutes audio (evidence: `Media_And_Volume/MediaControls.py`)
