# yassdev212/realtime_audio_transcription architecture

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

- Interactive diagram: https://gitdiagram.com/yassdev212/realtime_audio_transcription
- Repository: https://github.com/yassdev212/realtime_audio_transcription

## Overview

#### Purpose and Entry Points
This is a Windows-local real-time meeting transcription system: it captures system speaker audio, transcribes it on CUDA, displays live text in a transparent HUD, and persists finalized utterances for logs, search, and optional summaries.

Primary entry points:
- Live application: `main.py`
- Audio capture/preprocessing: `audio.py`
- Transcription/VAD worker: `engine.py`
- Semantic-search CLI: `search.py`
- Summary CLI and exit-time summary generation: `summarizer.py`

#### Runtime and Platform Boundary
The core runtime is Python on Windows. Audio capture depends on WASAPI loopback via PyAudioWPatch; the UI is a PyQt6 overlay with Win32 click-through behavior. GPU inference uses faster-whisper/CTranslate2 with NVIDIA CUDA. Core transcription, SQLite logging, and vector search are local; Groq is only an optional external LLM dependency.

Relevant paths: `main.py`, `audio.py`, `engine.py`, `overlay.py`.

#### Live Audio-to-Text Pipeline
`main.py` orchestrates a session and connects the capture, worker, UI, and persistence layers. `audio.py` captures Windows speaker output into an audio queue. The worker pipeline in `engine.py` downmixes stereo, resamples 48 kHz audio to Whisper’s 16 kHz input, converts PCM to float32, and processes accumulated speech segments.

The first VAD layer is an RMS-energy/pause gate that determines when to flush a phrase; faster-whisper’s built-in Silero VAD provides a second noise/speech filter before inference. This separates low-latency stream control from model-level speech cleanup.

Paths: `main.py`, `audio.py`, `engine.py`.

#### Transcription and HUD State Flow
`engine.py` runs the local `base.en` faster-whisper model through CTranslate2/CUDA. It emits interim/draft words while speech is active and a finalized transcript after a pause. Qt signals bridge the worker thread to the GUI thread, preventing transcription and audio work from blocking rendering.

`overlay.py` renders draft text differently from confirmed text, uses a borderless semi-transparent HUD, passes mouse input through to underlying Windows applications, and clears inactive content after silence.

Paths: `engine.py`, `overlay.py`, `main.py`.

#### Persistent Transcript and Vector Index
Finalized transcript segments are dual-written by the persistence layer: SQLite is the chronological, session-oriented source for exports and summaries; ChromaDB stores embeddings for semantic retrieval. `database.py` is the storage boundary shared by the live pipeline, summary workflow, and search workflow.

This split is intentional: relational session history supports deterministic transcript assembly, while ChromaDB supports meaning-based queries across past meeting content.

Paths: `database.py`, `engine.py`, `search.py`.

#### Search and Optional RAG
`search.py` is an independent CLI over the local ChromaDB index. It uses sentence-transformers to embed queries and retrieve semantically similar transcript chunks without network access. In `--ask` mode, retrieved context is passed to an LLM for synthesized answers; this introduces the optional Groq API boundary and requires `GROQ_API_KEY`.

Paths: `search.py`, `database.py`, `summarizer.py`.

#### Session Finalization and Summaries
On Ctrl+C/application shutdown, `main.py` cleanly terminates the live pipeline and retrieves the session transcript from SQLite. `summarizer.py` can then produce a raw export or, when configured, call Groq to generate an executive meeting report under `summaries/`. It also serves as a standalone CLI for recent or named sessions.

Paths: `main.py`, `summarizer.py`, `database.py`.

#### Supporting Evaluation
`benchmark.py` appears to support transcription-performance or quality evaluation, separate from the production audio/HUD path. Design rationale and benchmark history are documented in `documentation.md`; demonstration media resides in `assets/demo2.png`.

Paths: `benchmark.py`, `documentation.md`, `assets/demo2.png`.

Main entry points: [`engine.py`](https://github.com/yassdev212/realtime_audio_transcription/blob/main/engine.py) (Transcription worker), [`summarizer.py`](https://github.com/yassdev212/realtime_audio_transcription/blob/main/summarizer.py) (Summary CLI), [`database.py`](https://github.com/yassdev212/realtime_audio_transcription/blob/main/database.py) (Persistence boundary), [`main.py`](https://github.com/yassdev212/realtime_audio_transcription/blob/main/main.py) (Live app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_live["Live transcription"]
  node_main["Live app<br/>Python entry point<br/>[main.py]"]
  node_audio["WASAPI capture<br/>audio capture<br/>[audio.py]"]
  node_audio_queue["Audio queue<br/>stream buffer<br/>[audio.py]"]
  node_engine["Transcription worker<br/>worker pipeline<br/>[engine.py]"]
  node_phrase_gate["RMS pause gate<br/>stream VAD<br/>[engine.py]"]
  node_audio_preprocess["Whisper audio prep<br/>signal processing<br/>[engine.py]"]
  node_whisper{{"faster-whisper CUDA<br/>local inference<br/>[engine.py]"}}
  node_qt_signals["Qt signal bridge<br/>thread boundary<br/>[engine.py]"]
  node_overlay["Transparent HUD<br/>PyQt6 overlay<br/>[overlay.py]"]
end

subgraph group_storage["Local persistence"]
  node_database["Persistence boundary<br/>storage service<br/>[database.py]"]
  node_sqlite[("SQLite session history<br/>relational store<br/>[database.py]")]
  node_chroma[("ChromaDB index<br/>vector store<br/>[database.py]")]
end

subgraph group_tools["CLI workflows"]
  node_search["Search CLI<br/>[search.py]"]
  node_query_embeddings["Sentence-transformers<br/>query embedding<br/>[search.py]"]
  node_summarizer["Summary CLI<br/>[summarizer.py]"]
  node_groq{{"Groq API<br/>optional external LLM<br/>[summarizer.py]"}}
  node_summaries["Summary files<br/>report output<br/>[summarizer.py]"]
end

node_main -->|"starts capture"| node_audio
node_audio -->|"speaker PCM"| node_audio_queue
node_audio_queue -->|"audio chunks"| node_engine
node_engine -->|"accumulated stream"| node_phrase_gate
node_phrase_gate -->|"speech phrase"| node_audio_preprocess
node_audio_preprocess -->|"16 kHz float32"| node_whisper
node_whisper -->|"draft and final text"| node_engine
node_engine -->|"worker updates"| node_qt_signals
node_qt_signals -->|"GUI-thread text state"| node_overlay
node_engine -->|"finalized segments"| node_database
node_database -->|"session rows"| node_sqlite
node_database -->|"embedded chunks"| node_chroma
node_main -->|"shutdown finalization"| node_summarizer
node_summarizer -->|"loads session transcript"| node_sqlite
node_summarizer -.->|"optional report prompt"| node_groq
node_summarizer -->|"writes report"| node_summaries
node_search -->|"embeds query"| node_query_embeddings
node_query_embeddings -->|"semantic query"| node_chroma
node_search -.->|"--ask context synthesis"| node_groq

click node_main "https://github.com/yassdev212/realtime_audio_transcription/blob/main/main.py"
click node_audio "https://github.com/yassdev212/realtime_audio_transcription/blob/main/audio.py"
click node_audio_queue "https://github.com/yassdev212/realtime_audio_transcription/blob/main/audio.py"
click node_engine "https://github.com/yassdev212/realtime_audio_transcription/blob/main/engine.py"
click node_phrase_gate "https://github.com/yassdev212/realtime_audio_transcription/blob/main/engine.py"
click node_audio_preprocess "https://github.com/yassdev212/realtime_audio_transcription/blob/main/engine.py"
click node_whisper "https://github.com/yassdev212/realtime_audio_transcription/blob/main/engine.py"
click node_qt_signals "https://github.com/yassdev212/realtime_audio_transcription/blob/main/engine.py"
click node_overlay "https://github.com/yassdev212/realtime_audio_transcription/blob/main/overlay.py"
click node_database "https://github.com/yassdev212/realtime_audio_transcription/blob/main/database.py"
click node_sqlite "https://github.com/yassdev212/realtime_audio_transcription/blob/main/database.py"
click node_chroma "https://github.com/yassdev212/realtime_audio_transcription/blob/main/database.py"
click node_search "https://github.com/yassdev212/realtime_audio_transcription/blob/main/search.py"
click node_query_embeddings "https://github.com/yassdev212/realtime_audio_transcription/blob/main/search.py"
click node_summarizer "https://github.com/yassdev212/realtime_audio_transcription/blob/main/summarizer.py"
click node_groq "https://github.com/yassdev212/realtime_audio_transcription/blob/main/summarizer.py"
click node_summaries "https://github.com/yassdev212/realtime_audio_transcription/blob/main/summarizer.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,node_audio,node_audio_queue,node_engine,node_phrase_gate,node_audio_preprocess,node_whisper,node_qt_signals,node_overlay toneBlue
class node_database,node_sqlite,node_chroma toneAmber
class node_search,node_query_embeddings,node_summarizer,node_groq,node_summaries toneMint
```

## Components

### Live transcription

Windows-local capture, inference, and HUD.

- [Live app](https://github.com/yassdev212/realtime_audio_transcription/blob/main/main.py): Python entry point · Orchestrates a transcription session and shutdown. · `main.py`
- [WASAPI capture](https://github.com/yassdev212/realtime_audio_transcription/blob/main/audio.py): audio capture · Captures Windows speaker loopback audio. · `audio.py`
- [Audio queue](https://github.com/yassdev212/realtime_audio_transcription/blob/main/audio.py): stream buffer · `audio.py`
- [Transcription worker](https://github.com/yassdev212/realtime_audio_transcription/blob/main/engine.py): worker pipeline · Processes buffered audio and emits draft and final text. · `engine.py`
- [RMS pause gate](https://github.com/yassdev212/realtime_audio_transcription/blob/main/engine.py): stream VAD · Flushes accumulated phrases after pauses. · `engine.py`
- [Whisper audio prep](https://github.com/yassdev212/realtime_audio_transcription/blob/main/engine.py): signal processing · Downmixes, resamples 48 kHz to 16 kHz, and converts PCM. · `engine.py`
- [faster-whisper CUDA](https://github.com/yassdev212/realtime_audio_transcription/blob/main/engine.py): local inference · Runs base.en with Silero VAD through CTranslate2/CUDA. · `engine.py`
- [Qt signal bridge](https://github.com/yassdev212/realtime_audio_transcription/blob/main/engine.py): thread boundary · Moves worker updates safely to the GUI thread. · `engine.py`
- [Transparent HUD](https://github.com/yassdev212/realtime_audio_transcription/blob/main/overlay.py): PyQt6 overlay · Shows draft and confirmed text with Win32 click-through. · `overlay.py`

### Local persistence

Session history and semantic retrieval stores.

- [Persistence boundary](https://github.com/yassdev212/realtime_audio_transcription/blob/main/database.py): storage service · Dual-writes finalized transcript segments. · `database.py`
- [SQLite session history](https://github.com/yassdev212/realtime_audio_transcription/blob/main/database.py): relational store · Chronological source for exports and summaries. · `database.py`
- [ChromaDB index](https://github.com/yassdev212/realtime_audio_transcription/blob/main/database.py): vector store · Semantic retrieval across transcript chunks. · `database.py`

### CLI workflows

Search and session-finalization tools.

- [Search CLI](https://github.com/yassdev212/realtime_audio_transcription/blob/main/search.py): CLI · Queries locally indexed meeting content. · `search.py`
- [Sentence-transformers](https://github.com/yassdev212/realtime_audio_transcription/blob/main/search.py): query embedding · Embeds semantic-search queries locally. · `search.py`
- [Summary CLI](https://github.com/yassdev212/realtime_audio_transcription/blob/main/summarizer.py): CLI · Exports or summarizes named and recent sessions. · `summarizer.py`
- [Groq API](https://github.com/yassdev212/realtime_audio_transcription/blob/main/summarizer.py): optional external LLM · Synthesizes RAG answers and executive reports when configured. · `summarizer.py`
- [Summary files](https://github.com/yassdev212/realtime_audio_transcription/blob/main/summarizer.py): report output · Generated executive reports are written here. · `summarizer.py`

## Connections

- Live app → WASAPI capture: starts capture
- WASAPI capture → Audio queue: speaker PCM
- Audio queue → Transcription worker: audio chunks
- Transcription worker → RMS pause gate: accumulated stream
- RMS pause gate → Whisper audio prep: speech phrase
- Whisper audio prep → faster-whisper CUDA: 16 kHz float32
- faster-whisper CUDA → Transcription worker: draft and final text
- Transcription worker → Qt signal bridge: worker updates
- Qt signal bridge → Transparent HUD: GUI-thread text state
- Transcription worker → Persistence boundary: finalized segments
- Persistence boundary → SQLite session history: session rows
- Persistence boundary → ChromaDB index: embedded chunks
- Live app → Summary CLI: shutdown finalization
- Summary CLI → SQLite session history: loads session transcript
- Summary CLI → Groq API: optional report prompt
- Summary CLI → Summary files: writes report
- Search CLI → Sentence-transformers: embeds query
- Sentence-transformers → ChromaDB index: semantic query
- Search CLI → Groq API: --ask context synthesis
