# const-me/whisper architecture

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

- Interactive diagram: https://gitdiagram.com/const-me/whisper
- Repository: https://github.com/const-me/whisper

## Overview

Whisper is a Windows speech-recognition library and application-facing API port of whisper.cpp. The main workflow loads a Whisper model, accepts audio from a file, stream, or microphone, converts it to model input, runs encoder/decoder inference, and exposes transcription results. The README also documents DirectCompute acceleration, voice-activity detection, profiling, a C# wrapper, and PowerShell scripting. The graph reflects those documented capabilities; sampled excerpts confirm key API, inference, and tensor-compute behavior, but do not expose every subsystem’s wiring.

Main entry points: [`Whisper/Whisper/ContextImpl.cpp`](https://github.com/const-me/whisper/blob/master/Whisper/Whisper/ContextImpl.cpp) (Transcription context), [`Whisper/API/iContext.cl.h`](https://github.com/const-me/whisper/blob/master/Whisper/API/iContext.cl.h) (COM-style API), [`WhisperNet/Context.cs`](https://github.com/const-me/whisper/blob/master/WhisperNet/Context.cs) (C# wrapper), [`Whisper/MF/AudioCapture.cpp`](https://github.com/const-me/whisper/blob/master/Whisper/MF/AudioCapture.cpp) (Microphone capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["API and clients"]
  node_native_api["COM-style API<br/>[iContext.cl.h]"]
  node_net["C&#35; wrapper<br/>[Context.cs]"]
  node_powershell["PowerShell commands<br/>[TranscribeFile.cs]"]
end

subgraph group_audio["Audio and speech"]
  node_audio_files["File audio<br/>[loadAudioFile.cpp]"]
  node_audio_stream["Audio stream<br/>[PcmReader.cpp]"]
  node_capture["Microphone capture<br/>[AudioCapture.cpp]"]
  node_vad["Voice activity detection"]
  node_mel["Mel spectrogram<br/>[melSpectrogram.cpp]"]
end

subgraph group_inference["Model inference"]
  node_model["Model loading<br/>[modelFactory.cpp]"]
  node_context["Transcription context<br/>[ContextImpl.cpp]"]
  node_result["Transcription results<br/>[TranscribeResult.h]"]
end

subgraph group_compute["Compute and diagnostics"]
  node_gpu["DirectCompute backend<br/>[WhisperContext.cpp]"]
  node_ml["GPU tensor operations<br/>[MlContext.cpp]"]
  node_d3d["D3D shader dispatch<br/>[shaders.cpp]"]
  node_cpu["CPU compute<br/>[MlContextCpu.cpp]"]
  node_hybrid["Hybrid inference<br/>[HybridContext.cpp]"]
  node_profiler["Performance profiler"]
end

node_user(("Application / user"))
node_mic(("Microphone"))
node_file["Audio file"]

node_user -->|"calls"| node_net
node_user -->|"runs"| node_powershell
node_net -->|"calls"| node_native_api
node_powershell -->|"uses"| node_native_api
node_native_api -->|"loads model"| node_model
node_native_api -->|"creates context"| node_context
node_file -->|"supplies audio"| node_audio_files
node_mic -->|"supplies audio"| node_capture
node_audio_files -->|"provides audio"| node_context
node_audio_stream -->|"provides audio"| node_context
node_capture -->|"provides audio"| node_context
node_capture -->|"processes audio"| node_vad
node_context -->|"creates features"| node_mel
node_context -->|"runs inference"| node_gpu
node_gpu -->|"uses tensor ops"| node_ml
node_ml -->|"dispatches shaders"| node_d3d
node_context -->|"produces"| node_result
node_net -->|"exposes"| node_result
node_gpu -->|"records timings"| node_profiler
node_context -.->|"uses CPU ops"| node_cpu
node_context -.->|"uses hybrid mode"| node_hybrid

click node_native_api "https://github.com/const-me/whisper/blob/master/Whisper/API/iContext.cl.h"
click node_net "https://github.com/const-me/whisper/blob/master/WhisperNet/Context.cs"
click node_powershell "https://github.com/const-me/whisper/blob/master/WhisperPS/Commands/TranscribeFile.cs"
click node_model "https://github.com/const-me/whisper/blob/master/Whisper/modelFactory.cpp"
click node_context "https://github.com/const-me/whisper/blob/master/Whisper/Whisper/ContextImpl.cpp"
click node_audio_files "https://github.com/const-me/whisper/blob/master/Whisper/MF/loadAudioFile.cpp"
click node_audio_stream "https://github.com/const-me/whisper/blob/master/Whisper/MF/PcmReader.cpp"
click node_capture "https://github.com/const-me/whisper/blob/master/Whisper/MF/AudioCapture.cpp"
click node_vad "https://github.com/const-me/whisper/blob/master/Whisper/Whisper/voiceActivityDetection.h"
click node_mel "https://github.com/const-me/whisper/blob/master/Whisper/Whisper/melSpectrogram.cpp"
click node_result "https://github.com/const-me/whisper/blob/master/Whisper/Whisper/TranscribeResult.h"
click node_gpu "https://github.com/const-me/whisper/blob/master/Whisper/Whisper/WhisperContext.cpp"
click node_ml "https://github.com/const-me/whisper/blob/master/Whisper/ML/MlContext.cpp"
click node_d3d "https://github.com/const-me/whisper/blob/master/Whisper/D3D/shaders.cpp"
click node_cpu "https://github.com/const-me/whisper/blob/master/Whisper/CPU/MlContextCpu.cpp"
click node_hybrid "https://github.com/const-me/whisper/blob/master/Whisper/Hybrid/HybridContext.cpp"
click node_profiler "https://github.com/const-me/whisper/blob/master/Whisper/Utils/ProfileCollection.cpp"

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_native_api,node_net,node_powershell,node_user toneBlue
class node_audio_files,node_audio_stream,node_capture,node_vad,node_mel toneAmber
class node_model,node_context,node_result toneMint
class node_gpu,node_ml,node_d3d,node_cpu,node_hybrid,node_profiler toneRose
class node_mic,node_file toneIndigo
```

## Components

### API and clients

- [COM-style API](https://github.com/const-me/whisper/blob/master/Whisper/API/iContext.cl.h): `Whisper/API/iContext.cl.h`
- [C# wrapper](https://github.com/const-me/whisper/blob/master/WhisperNet/Context.cs): `WhisperNet/Context.cs`
- [PowerShell commands](https://github.com/const-me/whisper/blob/master/WhisperPS/Commands/TranscribeFile.cs): `WhisperPS/Commands/TranscribeFile.cs`

### Audio and speech

- [File audio](https://github.com/const-me/whisper/blob/master/Whisper/MF/loadAudioFile.cpp): `Whisper/MF/loadAudioFile.cpp`
- [Audio stream](https://github.com/const-me/whisper/blob/master/Whisper/MF/PcmReader.cpp): `Whisper/MF/PcmReader.cpp`
- [Microphone capture](https://github.com/const-me/whisper/blob/master/Whisper/MF/AudioCapture.cpp): `Whisper/MF/AudioCapture.cpp`
- [Voice activity detection](https://github.com/const-me/whisper/blob/master/Whisper/Whisper/voiceActivityDetection.h): `Whisper/Whisper/voiceActivityDetection.h`
- [Mel spectrogram](https://github.com/const-me/whisper/blob/master/Whisper/Whisper/melSpectrogram.cpp): `Whisper/Whisper/melSpectrogram.cpp`

### Model inference

- [Model loading](https://github.com/const-me/whisper/blob/master/Whisper/modelFactory.cpp): `Whisper/modelFactory.cpp`
- [Transcription context](https://github.com/const-me/whisper/blob/master/Whisper/Whisper/ContextImpl.cpp): `Whisper/Whisper/ContextImpl.cpp`
- [Transcription results](https://github.com/const-me/whisper/blob/master/Whisper/Whisper/TranscribeResult.h): `Whisper/Whisper/TranscribeResult.h`

### Compute and diagnostics

- [DirectCompute backend](https://github.com/const-me/whisper/blob/master/Whisper/Whisper/WhisperContext.cpp): `Whisper/Whisper/WhisperContext.cpp`
- [GPU tensor operations](https://github.com/const-me/whisper/blob/master/Whisper/ML/MlContext.cpp): `Whisper/ML/MlContext.cpp`
- [D3D shader dispatch](https://github.com/const-me/whisper/blob/master/Whisper/D3D/shaders.cpp): `Whisper/D3D/shaders.cpp`
- [CPU compute](https://github.com/const-me/whisper/blob/master/Whisper/CPU/MlContextCpu.cpp): `Whisper/CPU/MlContextCpu.cpp`
- [Hybrid inference](https://github.com/const-me/whisper/blob/master/Whisper/Hybrid/HybridContext.cpp): `Whisper/Hybrid/HybridContext.cpp`
- [Performance profiler](https://github.com/const-me/whisper/blob/master/Whisper/Utils/ProfileCollection.cpp): `Whisper/Utils/ProfileCollection.cpp`

### Other components

- **Application / user**
- **Microphone**
- **Audio file**

## Connections

- Application / user → C# wrapper: calls
- Application / user → PowerShell commands: runs
- C# wrapper → COM-style API: calls
- PowerShell commands → COM-style API: uses
- COM-style API → Model loading: loads model
- COM-style API → Transcription context: creates context
- Audio file → File audio: supplies audio
- Microphone → Microphone capture: supplies audio
- File audio → Transcription context: provides audio
- Audio stream → Transcription context: provides audio
- Microphone capture → Transcription context: provides audio
- Microphone capture → Voice activity detection: processes audio
- Transcription context → Mel spectrogram: creates features
- Transcription context → DirectCompute backend: runs inference
- DirectCompute backend → GPU tensor operations: uses tensor ops
- GPU tensor operations → D3D shader dispatch: dispatches shaders
- Transcription context → Transcription results: produces
- C# wrapper → Transcription results: exposes
- DirectCompute backend → Performance profiler: records timings
- Transcription context → CPU compute: uses CPU ops
- Transcription context → Hybrid inference: uses hybrid mode
