# ak4off/vad-in-process-streaming-asr-decode architecture

> Architecture diagram of the GitHub repository ak4off/vad-in-process-streaming-asr-decode, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ak4off/vad-in-process-streaming-asr-decode
- Repository: https://github.com/ak4off/vad-in-process-streaming-asr-decode

## Overview

This repository is an in-memory, VAD-based streaming ASR decoder. The principal workflow loads the speech model once, finds input audio, slices speech-only chunks in memory, decodes them sequentially with optional prior-chunk prompt context, cleans and optionally seam-deduplicates text, then writes merged transcripts, timed WebVTT cues, and per-chunk TSV records. A separate optional CLI writes VAD chunks to disk. The README documents these branches; some implementation details, including output-writing code, were not included in the sampled excerpts.

Main entry points: [`decode_ctx_vad_vtt.py`](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py) (Decode driver), [`chunk_audio.py`](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/chunk_audio.py) (Speech chunking), [`inmemory_speech_dataset.py`](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/inmemory_speech_dataset.py) (In-memory dataset), [`conf/prompt_dynamic_language.yaml`](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/conf/prompt_dynamic_language.yaml) (Language prompt)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_decode["Decode orchestration"]
  node_driver["Decode driver"]
end

subgraph group_audio["Audio preparation"]
  node_file_scan["Audio discovery<br/>[chunk_audio.py]"]
  node_audio_load["Load and resample<br/>[chunk_audio.py]"]
  node_vad["Silero VAD"]
  node_chunking["Speech chunking<br/>[chunk_audio.py]"]
  node_standalone_cli["Standalone chunk CLI<br/>[chunk_audio.py]"]
end

subgraph group_inference["Inference and text"]
  node_memory_dataset["In-memory dataset"]
  node_dataset_class["Configured dataset class"]
  node_prompt["Language prompt"]
  node_model_factory["Model factory"]
  node_asr_model["ASR model"]
  node_cleanup["Text cleanup"]
  node_seam_merge["Overlap deduplication"]
end

subgraph group_outputs["Outputs"]
  node_transcript["Merged transcript"]
  node_vtt["Timed VTT cues"]
  node_utterances["Chunk TSV"]
  node_chunk_files["Chunk WAV files<br/>[chunk_audio.py]"]
end

node_user(("Audio provider"))

node_user -->|"provides input"| node_driver
node_driver -->|"finds audio"| node_file_scan
node_driver -->|"loads once"| node_model_factory
node_model_factory -->|"constructs"| node_asr_model
node_driver -->|"loads VAD"| node_vad
node_driver -->|"requests chunks"| node_chunking
node_chunking -->|"reads audio"| node_audio_load
node_chunking -->|"detects speech"| node_vad
node_file_scan -->|"returns files"| node_driver
node_driver -->|"builds per chunk"| node_memory_dataset
node_memory_dataset -->|"loads dynamically"| node_dataset_class
node_memory_dataset -->|"uses template"| node_prompt
node_driver -->|"generates text"| node_asr_model
node_driver -->|"sanitizes output"| node_cleanup
node_driver -->|"deduplicates overlap"| node_seam_merge
node_driver -->|"writes merged text"| node_transcript
node_driver -->|"writes timed cues"| node_vtt
node_driver -->|"writes chunk records"| node_utterances
node_user -.->|"supplies audio"| node_standalone_cli
node_standalone_cli -.->|"uses chunking"| node_chunking
node_standalone_cli -.->|"writes WAV chunks"| node_chunk_files

click node_driver "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py"
click node_file_scan "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/chunk_audio.py"
click node_audio_load "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/chunk_audio.py"
click node_chunking "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/chunk_audio.py"
click node_memory_dataset "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/inmemory_speech_dataset.py"
click node_prompt "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/conf/prompt_dynamic_language.yaml"
click node_model_factory "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py"
click node_cleanup "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py"
click node_seam_merge "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py"
click node_transcript "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py"
click node_vtt "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py"
click node_utterances "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py"
click node_standalone_cli "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/chunk_audio.py"
click node_chunk_files "https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/chunk_audio.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_driver toneBlue
class node_file_scan,node_audio_load,node_vad,node_chunking,node_standalone_cli toneAmber
class node_memory_dataset,node_dataset_class,node_prompt,node_model_factory,node_asr_model,node_cleanup,node_seam_merge toneMint
class node_transcript,node_vtt,node_utterances,node_chunk_files toneRose
class node_user toneIndigo
```

## Components

### Decode orchestration

- [Decode driver](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py): `decode_ctx_vad_vtt.py`

### Audio preparation

- [Audio discovery](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/chunk_audio.py): `chunk_audio.py`
- [Load and resample](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/chunk_audio.py): `chunk_audio.py`
- **Silero VAD**
- [Speech chunking](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/chunk_audio.py): `chunk_audio.py`
- [Standalone chunk CLI](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/chunk_audio.py): `chunk_audio.py`

### Inference and text

- [In-memory dataset](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/inmemory_speech_dataset.py): `inmemory_speech_dataset.py`
- **Configured dataset class**
- [Language prompt](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/conf/prompt_dynamic_language.yaml): `conf/prompt_dynamic_language.yaml`
- [Model factory](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py): `decode_ctx_vad_vtt.py`
- **ASR model**
- [Text cleanup](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py): `decode_ctx_vad_vtt.py`
- [Overlap deduplication](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py): `decode_ctx_vad_vtt.py`

### Outputs

- [Merged transcript](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py): `decode_ctx_vad_vtt.py`
- [Timed VTT cues](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py): `decode_ctx_vad_vtt.py`
- [Chunk TSV](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/decode_ctx_vad_vtt.py): `decode_ctx_vad_vtt.py`
- [Chunk WAV files](https://github.com/ak4off/vad-in-process-streaming-asr-decode/blob/main/chunk_audio.py): `chunk_audio.py`

### Other components

- **Audio provider**

## Connections

- Audio provider → Decode driver: provides input
- Decode driver → Audio discovery: finds audio
- Decode driver → Model factory: loads once
- Model factory → ASR model: constructs
- Decode driver → Silero VAD: loads VAD
- Decode driver → Speech chunking: requests chunks
- Speech chunking → Load and resample: reads audio
- Speech chunking → Silero VAD: detects speech
- Audio discovery → Decode driver: returns files
- Decode driver → In-memory dataset: builds per chunk
- In-memory dataset → Configured dataset class: loads dynamically
- In-memory dataset → Language prompt: uses template
- Decode driver → ASR model: generates text
- Decode driver → Text cleanup: sanitizes output
- Decode driver → Overlap deduplication: deduplicates overlap
- Decode driver → Merged transcript: writes merged text
- Decode driver → Timed VTT cues: writes timed cues
- Decode driver → Chunk TSV: writes chunk records
- Audio provider → Standalone chunk CLI: supplies audio
- Standalone chunk CLI → Speech chunking: uses chunking
- Standalone chunk CLI → Chunk WAV files: writes WAV chunks
