# c5ln/asmr architecture

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

- Interactive diagram: https://gitdiagram.com/c5ln/asmr
- Repository: https://github.com/c5ln/asmr

## Overview

This repository replicates a keyboard acoustic side-channel classifier: recorded audio is segmented into keystrokes, transformed into mel-spectrograms, and classified among 36 keys. The main workflows are offline dataset generation and model training, plus standalone audio inference. The graph retains the separate preprocessing paths and model/checkpoint handoff. Relationships for training data loading and documented outputs rely on the README; source excerpts do not show every training-loop setup detail.

Main entry points: [`infer.py`](https://github.com/c5ln/asmr/blob/main/infer.py) (Inference workflow), [`train.py`](https://github.com/c5ln/asmr/blob/main/train.py) (Training loop), [`store_data.py`](https://github.com/c5ln/asmr/blob/main/store_data.py) (Offline augmentation), [`dataset.py`](https://github.com/c5ln/asmr/blob/main/dataset.py) (Keystroke isolation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Recordings and preprocessing"]
  node_mbp_audio[("MacBook recordings")]
  node_zoom_audio[("Zoom recordings")]
  node_isolation["Keystroke isolation<br/>[dataset.py]"]
  node_feature_transform["Mel features<br/>[dataset.py]"]
end

subgraph group_training["Dataset and training"]
  node_augmentation["Offline augmentation<br/>[store_data.py]"]
  node_prepared_data["Augmented tensors"]
  node_training_data["Training dataset<br/>[train.py]"]
  node_trainer["Training loop<br/>[train.py]"]
  node_classifier["CAFormer classifier<br/>[train.py]"]
  node_weights["Best model weights"]
  node_checkpoints["Training checkpoints"]
end

subgraph group_inference["Standalone inference"]
  node_audio_input["Audio file"]
  node_infer_entry["Inference workflow<br/>[infer.py]"]
  node_audio_loading["Audio loading<br/>[infer.py]"]
  node_stroke_extraction["Stroke extraction<br/>[infer.py]"]
  node_infer_features["Inference features<br/>[infer.py]"]
  node_infer_model["Inference classifier<br/>[infer.py]"]
  node_predictions["Key candidates"]
end

node_operator(("Researcher"))

node_operator -->|"provides recordings"| node_mbp_audio
node_operator -->|"provides recordings"| node_zoom_audio
node_mbp_audio -->|"loads and segments"| node_isolation
node_zoom_audio -.->|"can load"| node_isolation
node_isolation -->|"extracts strokes for"| node_feature_transform
node_operator -->|"generates dataset"| node_augmentation
node_augmentation -->|"loads keystrokes via"| node_isolation
node_augmentation -->|"computes mel features"| node_feature_transform
node_augmentation -->|"saves tensors"| node_prepared_data
node_operator -->|"starts training"| node_trainer
node_prepared_data -->|"supplies tensors"| node_training_data
node_training_data -->|"feeds batches"| node_trainer
node_trainer -->|"trains and evaluates"| node_classifier
node_trainer -->|"saves best weights"| node_weights
node_trainer -->|"saves checkpoints"| node_checkpoints
node_operator -->|"runs inference"| node_infer_entry
node_audio_input -->|"provides audio"| node_infer_entry
node_weights -->|"provides model weights"| node_infer_entry
node_infer_entry -->|"loads audio"| node_audio_loading
node_infer_entry -->|"extracts strokes"| node_stroke_extraction
node_infer_entry -->|"preprocesses strokes"| node_infer_features
node_infer_entry -->|"loads and predicts with"| node_infer_model
node_infer_model -->|"returns candidates"| node_predictions

click node_mbp_audio "https://github.com/c5ln/asmr/tree/main/MBPWavs"
click node_zoom_audio "https://github.com/c5ln/asmr/tree/main/Zoom"
click node_isolation "https://github.com/c5ln/asmr/blob/main/dataset.py"
click node_feature_transform "https://github.com/c5ln/asmr/blob/main/dataset.py"
click node_augmentation "https://github.com/c5ln/asmr/blob/main/store_data.py"
click node_training_data "https://github.com/c5ln/asmr/blob/main/train.py"
click node_trainer "https://github.com/c5ln/asmr/blob/main/train.py"
click node_classifier "https://github.com/c5ln/asmr/blob/main/train.py"
click node_infer_entry "https://github.com/c5ln/asmr/blob/main/infer.py"
click node_audio_loading "https://github.com/c5ln/asmr/blob/main/infer.py"
click node_stroke_extraction "https://github.com/c5ln/asmr/blob/main/infer.py"
click node_infer_features "https://github.com/c5ln/asmr/blob/main/infer.py"
click node_infer_model "https://github.com/c5ln/asmr/blob/main/infer.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_mbp_audio,node_zoom_audio,node_isolation,node_feature_transform toneBlue
class node_augmentation,node_prepared_data,node_training_data,node_trainer,node_classifier,node_weights,node_checkpoints toneAmber
class node_audio_input,node_infer_entry,node_audio_loading,node_stroke_extraction,node_infer_features,node_infer_model,node_predictions toneMint
class node_operator toneIndigo
```

## Components

### Recordings and preprocessing

- [MacBook recordings](https://github.com/c5ln/asmr/tree/main/MBPWavs): `MBPWavs`
- [Zoom recordings](https://github.com/c5ln/asmr/tree/main/Zoom): `Zoom`
- [Keystroke isolation](https://github.com/c5ln/asmr/blob/main/dataset.py): `dataset.py`
- [Mel features](https://github.com/c5ln/asmr/blob/main/dataset.py): `dataset.py`

### Dataset and training

- [Offline augmentation](https://github.com/c5ln/asmr/blob/main/store_data.py): `store_data.py`
- **Augmented tensors**
- [Training dataset](https://github.com/c5ln/asmr/blob/main/train.py): `train.py`
- [Training loop](https://github.com/c5ln/asmr/blob/main/train.py): `train.py`
- [CAFormer classifier](https://github.com/c5ln/asmr/blob/main/train.py): `train.py`
- **Best model weights**
- **Training checkpoints**

### Standalone inference

- **Audio file**
- [Inference workflow](https://github.com/c5ln/asmr/blob/main/infer.py): `infer.py`
- [Audio loading](https://github.com/c5ln/asmr/blob/main/infer.py): `infer.py`
- [Stroke extraction](https://github.com/c5ln/asmr/blob/main/infer.py): `infer.py`
- [Inference features](https://github.com/c5ln/asmr/blob/main/infer.py): `infer.py`
- [Inference classifier](https://github.com/c5ln/asmr/blob/main/infer.py): `infer.py`
- **Key candidates**

### Other components

- **Researcher**

## Connections

- Researcher → MacBook recordings: provides recordings (evidence: `README.md`)
- Researcher → Zoom recordings: provides recordings (evidence: `README.md`)
- MacBook recordings → Keystroke isolation: loads and segments (evidence: `dataset.py`)
- Zoom recordings → Keystroke isolation: can load
- Keystroke isolation → Mel features: extracts strokes for (evidence: `dataset.py`)
- Researcher → Offline augmentation: generates dataset (evidence: `README.md`)
- Offline augmentation → Keystroke isolation: loads keystrokes via (evidence: `store_data.py`)
- Offline augmentation → Mel features: computes mel features (evidence: `store_data.py`)
- Offline augmentation → Augmented tensors: saves tensors (evidence: `README.md`)
- Researcher → Training loop: starts training (evidence: `README.md`)
- Augmented tensors → Training dataset: supplies tensors (evidence: `README.md`)
- Training dataset → Training loop: feeds batches (evidence: `README.md`)
- Training loop → CAFormer classifier: trains and evaluates (evidence: `train.py`)
- Training loop → Best model weights: saves best weights (evidence: `train.py`)
- Training loop → Training checkpoints: saves checkpoints (evidence: `train.py`)
- Researcher → Inference workflow: runs inference (evidence: `README.md`)
- Audio file → Inference workflow: provides audio (evidence: `README.md`)
- Best model weights → Inference workflow: provides model weights (evidence: `README.md`)
- Inference workflow → Audio loading: loads audio (evidence: `infer.py`)
- Inference workflow → Stroke extraction: extracts strokes (evidence: `infer.py`)
- Inference workflow → Inference features: preprocesses strokes (evidence: `infer.py`)
- Inference workflow → Inference classifier: loads and predicts with (evidence: `infer.py`)
- Inference classifier → Key candidates: returns candidates (evidence: `infer.py`)
