Skip to content

paudang/PrivaSub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PrivaSub

Enterprise-grade, real-time English-to-Multi-Language translation subtitles powered entirely by local AI.

PrivaSub is a high-performance, privacy-first Live Subtitle application. It captures system audio or microphone input, transcribes English in real-time, and translates it to your target language seamlessly (currently defaulting to Vietnamese, with planned UI support for selecting among 200+ languages). Designed for zero-latency rendering and zero-disk I/O, PrivaSub is optimized to run smoothly on consumer hardware (e.g., RTX 2060, Apple Silicon) without ever sending your data to the cloud.


Key Features

Privacy First (100% Local)

No APIs, no cloud tracking, no subscriptions. Everything runs directly on your machine. Your audio and conversations never leave your device.

Blazing Fast Architecture

  • In-Memory Pipeline: Audio streams are buffered directly into RAM (io.BytesIO), bypassing disk I/O bottlenecks entirely.
  • Asynchronous Execution: GPU-intensive inference is handled on dedicated threads (asyncio.to_thread), guaranteeing that the WebSocket server remains non-blocking and ultra-responsive.
  • Translation Caching: Integrates an LRU cache at the translation layer, serving repeated short phrases instantly (0ms) without hitting the GPU.

"Big Tech" Zero-Jitter UX Design

We've engineered the UI to match the smoothness of industry-leading captioning tools (like Apple Dictation or Google Meet):

  • Live Box (Strict Append): The active typing area uses a strict Append-Only algorithm. This guarantees 0% layout jitter (no horizontal wiggling or slot-machine effects) by never manipulating previously rendered DOM nodes. Words flow in smoothly with a satisfying typing effect.
  • History Box (100% Accuracy): Once a sentence is finalized via VAD, the perfectly corrected English and its translated counterpart glide gracefully into the History Box.
  • DOM Virtualization: The frontend aggressively prunes old DOM nodes, ensuring the browser uses minimal memory even during multi-hour subtitle sessions.

Client-Side VAD (Voice Activity Detection)

Intelligently chunks audio streams locally in the browser when speech pauses (customizable silence thresholds), ensuring the AI models receive full sentence context for accurate translations.


Tech Stack

  • Backend: Python, FastAPI, Uvicorn, WebSockets.
  • AI Models:
    • STT: faster-whisper (CTranslate2)
    • Translation: facebook/nllb-200-distilled-600M (CTranslate2) - Capable of translating into 200+ languages.
  • Frontend: HTML5, Vanilla JS, Web Audio API, WebSockets.
  • E2E Testing: Playwright (Python).

Quick Start

PrivaSub is designed for cross-platform local deployment (Windows CUDA & macOS CPU/MPS).

1. Install Dependencies

Clone the repository and install the required Python packages:

pip install -r requirements.txt

2. Prepare the Translation Model

Download and convert the NLLB model into the highly optimized CTranslate2 format:

ct2-transformers-converter --model facebook/nllb-200-distilled-1.3B --output_dir nllb-200-distilled-1.3B-ct2 --quantization int8_float16

(Note: You can swap 1.3B for 600M depending on your VRAM).

3. Start the Server

Launch the FastAPI backend:

python -m uvicorn main:app --reload --host 0.0.0.0 --port 8000

4. Start Translating

  1. Open http://localhost:8000 in Google Chrome or Microsoft Edge.
  2. Grant microphone permissions when prompted.
  3. Select your Audio Source (Microphone or Stereo Mix for system audio).
  4. Click Start Listening and begin speaking!

End-to-End Testing

We provide a fully automated End-to-End (E2E) testing suite using Playwright. The suite simulates a real user by injecting audio directly into a virtual microphone and records the entire UI interaction.

Setup Playwright:

pip install playwright
playwright install chromium

Run the Test Suite: Ensure the FastAPI server is running, then execute:

python tests/test_ui.py

Test results, including UI screen recordings (.webm) and extracted transcriptions (transcription.txt), are automatically saved in the tests/results/ directory.


Built for performance. Built for privacy. Built for you.

About

100% Offline Real-time Desktop Live Captioner & Translator for Windows. Privacy-first, no cloud, no internet required.

Resources

Stars

5 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors