# biemster/gasr architecture

> Architecture diagram of the GitHub repository biemster/gasr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/biemster/gasr
- Repository: https://github.com/biemster/gasr

## Overview

##### Project Type and Purpose
- This is a specialized, native command-line tool for live transcription of audio input using ChromeOS’s offline SODA library.
- It takes audio via standard input (for example, using the ALSA sound system with arecord), processes it via the SODA engine, and outputs live transcriptions to stdout.
- The project includes a preparation step (prep.py) that handles the downloading of platform-specific libraries, language models, and even patches the dynamic linker for proper operation.

##### File Structure
- README.md – Contains the project’s description, usage instructions, and preparation steps.
- gasr.py – The main script for live transcription. This is the entry point of the client which reads audio, interacts with the SODA library, and outputs text.
- prep.py – A helper script responsible for setting up necessary assets (like the libsoda.so library and language models) and patching the dynamic linker. Think of it as an installer/configurer.
- soda_api_pb2.py – Likely generated Python code from Protocol Buffers describing the API messages for interacting with the SODA engine. This serves as a connector between the Python code and the C/C++ based SODA library.

##### The Core Components
a. Audio Input:
b. Main Processing Client:
- “gasr.py” as the main command-line client that receives audio data and calls the SODA API.
c. SODA Library Interface:
- “SODA API / libsoda.so” component which is the actual speech recognition engine.
- Also, illustrate “soda_api_pb2.py” as the API adapter that mediates between gasr.py and the SODA engine.
d. Setup and Configuration:
- “prep.py” as a preparation/setup module that downloads and patches the SODA library and language model. Use this to indicate that there is an initialization or installation phase.
e. Output:
- A component for the transcription output (stdout), possibly with a label “Live Transcription Output.”

##### Architectural Patterns and Design Principles
- The separation of concerns: Prep (setup phase) is decoupled from the live recognition (runtime phase).
- The design is modular despite its simplicity—with clearly defined roles for audio capture, audio processing, and system preparation.

##### Technologies and Tools
- Python for scripting (gasr.py and prep.py).
- ALSA for audio capture (through arecord).
- ChromeOS SODA library (libsoda.so) for the speech recognition engine.
- Protocol Buffers (soda_api_pb2.py) for the API interface definitions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Runtime Transcription Phase"
        A["Audio Capture (ALSA arecord)"]:::external
        B["gasr.py (Main Processing)"]:::internal
        C["soda_api_pb2.py (API Interface)"]:::internal
        D["SODA API / libsoda.so (Speech Recognition)"]:::external
        E["Live Transcription Output (stdout)"]:::output
    end

    subgraph "Setup Phase"
        F["prep.py (Setup Phase)"]:::internal
    end

    subgraph "Documentation"
        G["README.md (Documentation)"]:::documentation
    end

    A -->|"audio_input"| B
    B -->|"calls"| C
    C -->|"invokes"| D
    B -->|"outputs"| E
    F -.->|"initializes"| D

    click B "https://github.com/biemster/gasr/blob/main/gasr.py"
    click F "https://github.com/biemster/gasr/blob/main/prep.py"
    click C "https://github.com/biemster/gasr/blob/main/soda_api_pb2.py"
    click G "https://github.com/biemster/gasr/blob/main/README.md"

    classDef internal fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef output fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef documentation fill:#ADD8E6,stroke:#333,stroke-width:2px;
```
