Swar (ΰ€Έΰ₯ΰ€΅ΰ€°) is an open-source, privacy-first, self-hosted reference stack for automated speech recognition (ASR), acoustic speaker diarization, and structured meeting intelligence.
Designed for organizations and developers who need 100% local, air-gapped data confidentiality (e.g. legal depositions, healthcare consultations, and internal executive meetings), Swar combines modern open-source foundationsβFaster-Whisper Turbo, SpeechBrain ECAPA-TDNN, PostgreSQL with pgvector, and Google Geminiβinto a cohesive, containerized pipeline.
- Core Capabilities & Scope
- Architecture Overview
- Quickstart (Docker)
- Python SDK & CLI Usage
- REST API Documentation
- Database Schema
- Production Hardening & Security Checklist
- Documentation Sitemap
- Hardware Sizing & FAQ
- ποΈ Pluggable Multi-Provider ASR Engine: Seamlessly switch between Deepgram Nova-2 / Nova-3 (ultra-high accuracy & speed), Groq Cloud Whisper (LPU acceleration), ElevenLabs Scribe, and Local Faster-Whisper Turbo (100% air-gapped on CUDA/CPU).
- π 100% Air-Gapped / Local Operation Option: Audio decoding, VAD slicing, local Whisper transcription, and ECAPA speaker embeddings run completely on your local GPU containerβzero audio exfiltration.
- π Multilingual ASR: Transcribe or translate speech across 99+ supported languages with automatic language detection and confidence scoring.
-
π¬ Acoustic-First VAD Segmentation: Separates dialogue turns based on physical silence pauses (
$\ge 280\text{ms}$ ) and acoustic energy drops rather than heuristic punctuation. - π‘οΈ Circular Self-Reflection Padding: Eliminates neighbor voice bleed on short utterances ("Yeah", "Okay") by circularly repeating the target speaker's syllables up to 2.5s.
- π Adaptive Graph Diarization: Clusters 192-dimensional ECAPA-TDNN embeddings using normalized graph Laplacians, Eigengap heuristic estimation, and SciPy hierarchical linkage.
-
β Multi-Sample Gaussian Voiceprint Library: Persists speaker acoustic profiles in PostgreSQL
pgvector, updating running centroids ($\mathbf{c}_{t+1} = \frac{N\mathbf{c}_t + \mathbf{e}}{N+1}$ ) across recordings. - π§ Gemini Meeting Intelligence: Extracts executive summaries, timestamped chapters, speaker action items, and key notes via Google Gemini 2.5 Flash.
- π§Ή 48-Hour Auto-Purge Lifecycle: Automatic MinIO bucket lifecycle purging for heavy raw media while preserving lightweight transcripts and metadata.
-
βοΈ Biometric GDPR Compliance: One-click Right-to-be-Forgotten profile deletion (
DELETE /api/speaker/:id) with persistent audit logs.
ββββββββββββββββββββββββββ
β Swar Web Client β ββββ Modern Dark UI (React + Vanilla CSS)
β (http://localhost:5173)β
βββββββββββββ¬βββββββββββββ
β HTTP / REST
βΌ
ββββββββββββββββββββββββββ
β Fastify API Gateway β ββββ Node.js / BullMQ Queue Dispatcher
β (http://localhost:3000)β
βββββββ¬βββββββββββββ¬ββββββ
β β
βΌ βΌ
βββββββββββββ βββββββββββββββ ββββββββββββββββββββββββββββββββββ
βMinIO (S3) β β PostgreSQL β β Cloud ASR Providers β
β 48h Auto β β (pgvector) β β (Deepgram, Groq, ElevenLabs) β
βββββββ¬ββββββ ββββββββ¬βββββββ βββββββββββββββββ²βββββββββββββββββ
β β β HTTPS REST / SDK
βΌ βΌ β (Word Timestamps)
βββββββββββββββββββββββββββββββββββββββββββββββββββ΄βββββββββββ
β Unified GPU Worker (Faster-Whisper + SpeechBrain on CUDA) β
β βββ 1. FFmpeg 16kHz PCM S16LE Audio Extraction β
β βββ 2. Pluggable ASR (Deepgram / Groq / Eleven / Local) β
β βββ 3. Acoustic VAD Pause Slicing (>= 280ms) β
β βββ 4. 80Hz Butterworth High-Pass + RMS Normalization β
β βββ 5. ECAPA-TDNN Batched 192-dim Vector Extraction β
β βββ 6. Mutual k-NN Laplacian Graph & Eigengap Diarization β
β βββ 7. Multi-Sample Voiceprint Identification β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Docker Desktop (with WSL2 backend on Windows)
- NVIDIA GPU with NVIDIA Container Toolkit (Recommended for CUDA acceleration; falls back to CPU if unavailable).
git clone https://github.com/your-org/swar.git
cd swar
cp .env.example .envdocker compose up -d --build# Provide GROQ_API_KEY in .env or pass directly
ASR_PROVIDER=groq docker compose -f docker-compose.yml -f docker-compose.groq.yml up -d --build# Provide ELEVENLABS_API_KEY in .env or pass directly
ASR_PROVIDER=elevenlabs docker compose -f docker-compose.yml -f docker-compose.elevenlabs.yml up -d --build# Provide DEEPGRAM_API_KEY in .env or pass directly
ASR_PROVIDER=deepgram docker compose -f docker-compose.yml -f docker-compose.deepgram.yml up -d --build- Swar UI: http://localhost:5173
- Fastify Backend API: http://localhost:3000
- MinIO Console: http://localhost:9001 (
minioadmin/minioadmin)
POST /api/upload?language=hi&task=transcribe&asr_provider=deepgram
- Content-Type:
multipart/form-data(file) - Query Parameters:
language: ISO language code (e.g.en,hi,es,fr, or omit for auto-detect).task:transcribe(default) ortranslate(translate to English).asr_provider:deepgram(default cloud),groq,elevenlabs, orlocal(default local).
- Response:
{ "jobId": "7bdc90af-606d-4959-8ff4-5f50438cf188", "status": "processing" }
GET /api/job/:jobId
- Response:
{ "job": { "id": "7bdc90af-...", "status": "completed", "filename": "weekly_sync.mp4" }, "transcripts": [ { "speaker_name": "Raj Shamani", "start_time": 0.0, "end_time": 4.2, "text": "Welcome to the podcast everyone." } ], "benchmarks": { "gpu_time_ms": 1250, "cpu_time_ms": 1420, "detected_language": "hi", "detected_prob": 0.98, "asr_provider": "deepgram" } }
GET /api/jobs
- Response:
{ "jobs": [ { "id": "7bdc90af-...", "status": "completed", "filename": "weekly_sync.mp4", "asr_provider": "groq", "detected_language": "en", "num_speakers": 4, "num_segments": 32, "total_time_ms": 3450, "created_at": "2026-09-02T05:30:00.000Z" } ] }
GET /api/job/:jobId/media
- Action: Direct HTTP media streaming from MinIO storage with
Content-Typeheaders (video/mp4,audio/mpeg, etc.) and HTTP range request support for smooth scrubbing.
DELETE /api/job/:jobId
- Action: Cascading deletion of job metadata, transcripts, benchmarks, meeting intelligence, and underlying MinIO audio/video objects.
POST /api/speaker/rename
- Body:
{ "jobId": "...", "oldName": "Speaker 1", "newName": "Raj Shamani" }
POST /api/speaker/enroll
- Body:
{ "name": "Raj Shamani", "jobId": "...", "speakerName": "Speaker 1" } - Action: Computes a 192-dimensional acoustic centroid from the speaker's turns and updates their profile via running Gaussian averaging.
GET /api/speakers/enrolledβ List all enrolled voiceprints.DELETE /api/speaker/:idβ Permanently removes the biometric vector from PostgreSQL and logs the deletion tovoiceprint_audit_logs.
GET /api/job/:jobId/summaryβ Fetch stored meeting intelligence.POST /api/job/:jobId/summarizeβ Generate executive summaries, action items, chapters, and key decisions via Gemini 2.5 Flash.
-- Core job metadata
CREATE TABLE jobs (
id UUID PRIMARY KEY,
status VARCHAR(50) NOT NULL,
filename VARCHAR(500),
video_length_secs FLOAT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Transcribed dialogue turns
CREATE TABLE transcripts (
id SERIAL PRIMARY KEY,
job_id UUID REFERENCES jobs(id) ON DELETE CASCADE,
speaker_name VARCHAR(255),
text TEXT NOT NULL,
start_time FLOAT NOT NULL,
end_time FLOAT NOT NULL
);
-- Performance telemetry & engine benchmarking
CREATE TABLE benchmarks (
job_id UUID PRIMARY KEY REFERENCES jobs(id) ON DELETE CASCADE,
upload_time_ms INT,
gpu_time_ms INT,
cpu_time_ms INT,
total_time_ms INT,
detected_language VARCHAR(50),
detected_prob FLOAT,
num_speakers INT,
num_segments INT,
asr_provider VARCHAR(50) DEFAULT 'local',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Meeting intelligence & notes
CREATE TABLE meeting_intelligence (
job_id UUID PRIMARY KEY REFERENCES jobs(id) ON DELETE CASCADE,
executive_summary TEXT,
key_notes JSONB,
action_items JSONB,
chapters JSONB,
decisions JSONB,
raw_markdown TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Multi-sample biometric voiceprint library
CREATE TABLE enrolled_speakers (
id SERIAL PRIMARY KEY,
name VARCHAR(255) UNIQUE NOT NULL,
embedding vector(192) NOT NULL,
sample_count INT DEFAULT 1,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- GDPR / Biometric audit trail
CREATE TABLE voiceprint_audit_logs (
id SERIAL PRIMARY KEY,
speaker_name VARCHAR(255) NOT NULL,
action VARCHAR(50) NOT NULL,
details TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);Swar can be used headless as a standalone Python library or command-line utility without Docker:
# 1. Install locally
pip install -e .
# 2. Run via Terminal CLI (using Deepgram Nova-2/Nova-3)
export DEEPGRAM_API_KEY="your-deepgram-api-key"
swar interview.mp4 --provider deepgram --export-srt subtitles.srt --export-md report.md
# Or run with Groq Cloud, ElevenLabs, or 100% Local Whisper
swar podcast.mp3 --provider groq --lang hi
swar audio.wav --provider local --device cuda
# 3. Use in Python code
from swar import SwarEngine
# Initialize with Deepgram ASR engine
engine = SwarEngine(asr_provider="deepgram", device="cuda")
result = engine.process("podcast.mp3", language="en")
print(f"ASR Provider: {result.asr_provider}")
print(f"Detected Language: {result.language} ({result.language_prob*100:.1f}%)")
for turn in result.turns:
print(f"[{turn.start:.1f}s β {turn.end:.1f}s] {turn.speaker}: {turn.text}")When deploying Swar into production environments, review the following security baseline:
| Security Domain | Developer Default | Production Recommendation |
|---|---|---|
| Database & MinIO Credentials | postgres:postgres, minioadmin |
Rotate secrets in .env and pass via AWS Secrets Manager or HashiCorp Vault. |
| CORS Policy | Permissive for dev (origin: '*') |
Restrict origin to trusted frontend domain in Fastify server configuration. |
| Rate Limiting & DoS | None | Add @fastify/rate-limit (e.g. max 10 uploads/min per IP) or Cloudflare WAF. |
| API Authentication | Open endpoints | Enforce Bearer JWT or API Key middleware on all /api/* routes. |
| File Validation | MIME type header | Validate magic bytes (audio header signatures) on backend upload streams. |
- ποΈ ARCHITECTURE.md: Deep dive into the software engineering architecture, microservices, queue protocols, and data pipelines.
- π ABOUT.md: High-level explanation of the problem, value proposition, and user experience.
- π§ ALGORITHMS.md: Mathematical and AI engineering documentation covering ECAPA-TDNN embeddings, Graph Laplacians, Cannot-Link constraints, and Hungarian macro-window matching.
- βοΈ DEPLOYMENT.md: Production hybrid-cloud hosting guide (Modal.com Serverless GPU + AWS EC2).
- π₯οΈ frontend/README.md: React client architecture, CSS tokens, and UI component guide.
| Environment | Minimum Spec | Recommended Spec | Inference Speed (10 min audio) |
|---|---|---|---|
| Local Dev (Consumer GPU) | NVIDIA GTX 1650 (4GB VRAM), 8GB RAM | NVIDIA RTX 3060 / 4060 (8GB+ VRAM), 16GB RAM | ~45s β 75s |
| Cloud Dedicated GPU | AWS g4dn.xlarge (NVIDIA T4 16GB) |
AWS g5.xlarge (NVIDIA A10G 24GB) |
~15s β 25s |
| Serverless GPU | Modal.com T4 GPU ($0.000164/s) | Modal.com L4 / A10G GPU | ~12s β 18s |
| CPU-Only Fallback | 4 vCPUs, 8GB RAM | 8 vCPUs, 16GB RAM | ~3m β 5m |
If worker_gpu exits with a CUDA error:
# Verify NVIDIA GPU is visible inside Docker
docker run --rm --gpus all nvidia/cuda:12.1.0-base-ubuntu22.04 nvidia-smiIf a port is already in use by another application:
- Modify the host-side port mappings in
docker-compose.yml(e.g. change"3000:3000"to"3001:3000").
To reset all state, run the provided cleanup utility:
python clean.pyMIT License. Created with β€οΈ for high-precision speech intelligence.
