How kelvinwch/keyboard-acoustic-side-channel-attack works
This is an end-to-end acoustic keystroke classification project: record labeled key sounds, isolate individual presses, convert clips to spectrogram images, train a CoAtNet classifier, then classify live microphone input. The inference script can optionally send predicted characters to Ollama for text correction. The README documents the offline stage handoffs; the sampled scripts show the model-loading, audio-processing, and optional HTTP integration. Generated data and model directories are described in the README but are not present in the supplied tree.
Main entry points: infer.py Predicted characters · record.py Keystroke recorder · isolate.py Press isolator · spectrogram.py Spectrogram generator
Components 14
Audio capture
- Keystroke recorder
1_collect/record.py - Raw recordings
Signal preparation
- Press isolator
2_preprocess/isolate.py - Press clips
- Spectrogram generator
2_preprocess/spectrogram.py - Spectrogram images
Model training
- CoAtNet trainer
3_train/train.py - Trained classifier
Live inference
- Live key inference
4_infer/infer.py - Predicted characters
4_infer/infer.py - Corrected text
4_infer/infer.py
Other components
- Keyboard operator
- Microphone
- Ollama Gemma
Connections 15
- Keyboard operator → Keystroke recorder: enters key presses
README.md - Microphone → Keystroke recorder: supplies audio
1_collect/record.py - Keystroke recorder → Raw recordings: saves recordings
1_collect/record.py - Raw recordings → Press isolator: reads recordings
README.md - Press isolator → Press clips: writes press clips
README.md - Press clips → Spectrogram generator: reads clips
README.md - Spectrogram generator → Spectrogram images: writes images
README.md - Spectrogram images → CoAtNet trainer: trains from images
README.md - CoAtNet trainer → Trained classifier: saves checkpoint
3_train/train.py - Microphone → Live key inference: streams audio
4_infer/infer.py - Trained classifier → Live key inference: loads checkpoint
4_infer/infer.py - Live key inference → Predicted characters: predicts keys
4_infer/infer.py - Predicted characters → Ollama Gemma: optionally requests correction
4_infer/infer.py - Ollama Gemma → Corrected text: returns correction
4_infer/infer.py - Predicted characters → Corrected text: uses raw text if unavailable
4_infer/infer.py