# gaviral/voice-text-ai-demo architecture

> Architecture diagram of the GitHub repository gaviral/voice-text-ai-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gaviral/voice-text-ai-demo
- Repository: https://github.com/gaviral/voice-text-ai-demo

## Overview

##### Main Components
- API Layer (FastAPI): Represented by “app.py,” this is where all HTTP endpoints are defined and routed.
- Core AI/ML Models/Modules:
- Speech Recognition: Using the Whisper model.
- Speaker Diarization: Hosted via PyAnnote.
- Text Translation: Using MarianMT (Helsinki-NLP).
- NLP Pipelines: For sentiment analysis, compliance detection, and semantic similarity (using Hugging Face Transformers and Sentence Transformers).
- External Dependencies: Include an external resource block (if applicable) for obtaining Hugging Face tokens (HF_AUTH_TOKEN) and any libraries installed via requirements.txt.
- Client/Consumer: Show that consumers of this service interact with the endpoints via HTTP (POST requests).

##### Relationships and Data Flow
- For speech transcription endpoints, illustrate the flow from the API to the Whisper model.
- For diarization, flow the request to PyAnnote.
- For text analysis endpoints, show the flow into the appropriate NLP processing modules.
- If combined pipelines are used, indicate a sequential flow where the result from one module (e.g., transcription) is fed into another module (e.g., sentiment analysis or compliance check).

##### Architectural Patterns & Design Principles
- Microservice Design: Although contained in a single container, the architecture logically separates functionalities into distinct processing modules.
- Containerization: Highlight that the entire service is deployed via Docker for consistent environments and scalability.
- Modularity: Emphasize the loosely-coupled design where each endpoint encapsulates a separate AI functionality, making the system easier to extend.

##### Technical Stack & Technologies
- FastAPI for the web framework.
- Docker for containerization.
- Libraries/Models: Whisper, PyAnnote, MarianMT, Hugging Face Transformers, and Sentence Transformers.

##### Additional Elements
- And label API endpoints (as listed in the README) so that interactions become clear.
- Annotations showing optional parameters (like threshold and max_results) for compliance detection.
- That the system leverages containerization by optionally depicting environment variables (e.g., HF_AUTH_TOKEN and LOW_MEMORY) which affect runtime behavior.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client("Client (HTTP POST)"):::external
    DOC("Project Documentation (README)"):::external
    DEPS("Dependency Setup (Libraries, HF_AUTH_TOKEN, LOW_MEMORY)"):::external

    Client -->|"HTTPRequest"| API

    DOC -->|"describes"| API
    DEPS -->|"installs"| API

    subgraph "Docker Container (Deployment)"
        direction TB
        DCK("Deployment Config"):::externalConf
        API["API Gateway (FastAPI)"]:::apiLayer
        ST["Speech Transcription (Whisper)"]:::mlModule
        SD["Speaker Diarization (PyAnnote)"]:::mlModule
        TT["Text Translation (MarianMT)"]:::mlModule
        NLP["NLP Pipelines (Sentiment Analysis & Compliance Detection)"]:::mlModule
    end

    DCK --> API
    API -->|"routesToTranscription"| ST
    API -->|"routesToDiarization"| SD
    API -->|"routesToTranslation"| TT
    API -->|"routesToTextAnalysis"| NLP
    ST -->|"feedsTranscript"| NLP

    click API "https://github.com/gaviral/voice-text-ai-demo/blob/main/app.py"
    click DCK "https://github.com/gaviral/voice-text-ai-demo/tree/main/Dockerfile"
    click DEPS "https://github.com/gaviral/voice-text-ai-demo/blob/main/requirements.txt"
    click DOC "https://github.com/gaviral/voice-text-ai-demo/blob/main/README.md"

    classDef apiLayer fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef mlModule fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef external fill:#ffcc00,stroke:#000,stroke-width:2px;
    classDef externalConf fill:#ffcc00,stroke:#000,stroke-width:2px;
```
