Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ComplianceAI β€” Call Center Compliance Platform

AI-powered call center compliance monitoring with multi-stage NLP analysis, SOP validation, English translation layer, and semantic search.


Overview

ComplianceAI analyzes call center recordings to automatically validate Standard Operating Procedure (SOP) compliance, extract payment analytics, detect customer sentiment, and provide explainable AI (XAI) justifications β€” all from a single API call.

Supports Tanglish (Tamil + English) and Hinglish (Hindi + English) conversations using AssemblyAI for transcription and Google Gemini for NLP analysis and internal English translation.


Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Frontend (React)                  β”‚
β”‚         Corporate Dashboard  β€’  Port 3000            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚ REST API  (x-api-key header)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Space A β€” The Brain  (Port 8000)        β”‚
β”‚                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚              Analysis Pipeline               β”‚    β”‚
β”‚  β”‚                                             β”‚    β”‚
β”‚  β”‚  AssemblyAI  β†’  Clean  β†’  Translate (EN)    β”‚    β”‚
β”‚  β”‚      ↓              ↓           ↓           β”‚    β”‚
β”‚  β”‚  Transcribe    Original     Gemini LLM      β”‚    β”‚
β”‚  β”‚  (external)   (returned)   (analysis)       β”‚    β”‚
β”‚  β”‚                                 ↓           β”‚    β”‚
β”‚  β”‚              FAISS Vector DB (English embed) β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                                                      β”‚
β”‚   API Gateway  β€’  Pydantic Strict  β€’  JSON Healing   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β–Ό                       β–Ό
     AssemblyAI API           Google Gemini API
   (Speech-to-Text)       (Translation + Analysis)

Analysis Pipeline (Strict Order)

1. Validate x-api-key
2. Validate request body (Pydantic)
3. Base64 decode + upload to AssemblyAI β†’ get transcript
4. Clean transcript (remove fillers, repeated words)
5. Translate to English via Gemini [INTERNAL β€” not returned]
6. Analyze English transcript with Gemini β†’ JSON
7. If JSON invalid β†’ 3-pass agentic healing loop
8. Validate with Pydantic schemas
9. Store in FAISS (embed from English, store original + English)
10. Return response with original cleaned transcript

Features

Feature Description
AssemblyAI Transcription Cloud speech-to-text with speaker labels, auto language detection
English Translation Layer Gemini translates Tanglish/Hinglish internally for accurate LLM analysis
SOP Validation 5-step compliance check with boolean results and 0–1 score
Explainable AI (XAI) Gemini quotes the transcript to justify every SOP decision
Analytics Extraction Payment preference, rejection reason, sentiment β€” strict enums
Keyword Extraction 5–10 grounded keywords extracted from transcript
Agentic JSON Healing 3-pass self-healing loop when Gemini returns malformed JSON
FAISS Vector Search Semantic search over all analyzed calls; query also translated before embedding
Request Logging Every request persisted to logs/requests/<uuid>.json
API Authentication x-api-key header enforcement on all endpoints
Health Monitoring /health endpoint with per-service status

API Reference

POST /analyze

Headers: x-api-key: <your-key> Β· Content-Type: application/json

Request:

{
  "language": "Tamil",
  "audioFormat": "mp3",
  "audioBase64": "<base64-encoded-mp3>"
}

Response:

{
  "status": "success",
  "language": "Tamil",
  "transcript": "Vanakkam sir, ungal account pathi pesalam...",
  "summary": "Agent greeted the customer and verified account details. Customer expressed difficulty paying full amount. Agent offered EMI plan which customer agreed to.",
  "sop_validation": {
    "greeting": true,
    "identification": true,
    "problemStatement": true,
    "solutionOffering": true,
    "closing": false,
    "complianceScore": 0.8,
    "adherenceStatus": "FOLLOWED",
    "explanation": "Agent opened with 'Vanakkam sir' confirming greeting. Identity verified via account number. Customer stated 'full payment difficult' β€” problem captured. EMI was proposed as solution. Call ended abruptly without formal closing."
  },
  "analytics": {
    "paymentPreference": "EMI",
    "rejectionReason": "NONE",
    "sentiment": "Positive"
  },
  "keywords": ["EMI", "payment", "account", "loan", "interest"]
}

Note: English translation is used internally for analysis accuracy. Only the original cleaned transcript is returned.


POST /search

Search across all analyzed call transcripts using semantic similarity. The query is automatically translated to English before embedding for consistent vector space alignment.

Request:

{ "query": "customer refused EMI due to high interest", "top_k": 5 }

Response:

{
  "status": "success",
  "results": [
    {
      "transcript": "<original cleaned transcript>",
      "score": 0.87,
      "metadata": { "language": "Tamil" }
    }
  ]
}

GET /health

Returns per-service status. No auth required.

{
  "status": "ok",
  "services": {
    "api": "ok",
    "gemini": "configured",
    "faiss": { "status": "ok", "stored_transcripts": 12 }
  }
}

Enum Reference

Field Allowed Values
language Tamil Β· Hindi
audioFormat mp3
adherenceStatus FOLLOWED Β· NOT_FOLLOWED
paymentPreference EMI Β· FULL_PAYMENT Β· PARTIAL_PAYMENT Β· DOWN_PAYMENT
rejectionReason HIGH_INTEREST Β· BUDGET_CONSTRAINTS Β· ALREADY_PAID Β· NOT_INTERESTED Β· NONE
sentiment Positive Β· Neutral Β· Negative

Project Structure

HCL-Guvi/
β”œβ”€β”€ backend/
β”‚   └── space_a/                       # Single backend service (Port 8000)
β”‚       β”œβ”€β”€ main.py                    # FastAPI app + CORS + routing
β”‚       β”œβ”€β”€ logging_config.py          # Structured logging setup
β”‚       β”œβ”€β”€ requirements.txt
β”‚       β”œβ”€β”€ .env
β”‚       β”œβ”€β”€ routers/
β”‚       β”‚   β”œβ”€β”€ analyze.py             # POST /analyze  (full pipeline)
β”‚       β”‚   β”œβ”€β”€ search.py              # POST /search   (semantic search)
β”‚       β”‚   └── health.py              # GET  /health
β”‚       β”œβ”€β”€ services/
β”‚       β”‚   β”œβ”€β”€ audio_service.py       # AssemblyAI transcription client
β”‚       β”‚   β”œβ”€β”€ gemini_service.py      # Clean + Translate + Analyze + JSON Heal
β”‚       β”‚   └── faiss_service.py       # MiniLM embeddings + FAISS IndexFlatIP
β”‚       β”œβ”€β”€ models/
β”‚       β”‚   └── schemas.py             # Strict Pydantic v2 request/response models
β”‚       └── utils/
β”‚           └── logging_utils.py       # Per-request JSON log files
└── frontend/                          # React Dashboard (Port 3000)
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ App.js / App.css           # Charcoal/Red/Yellow design system
    β”‚   β”œβ”€β”€ components/
    β”‚   β”‚   β”œβ”€β”€ AnalyzeForm.js         # Drag-and-drop MP3 upload
    β”‚   β”‚   β”œβ”€β”€ ResultDisplay.js       # SOP ring, analytics badges, raw JSON view
    β”‚   β”‚   β”œβ”€β”€ SearchPanel.js         # Semantic search UI
    β”‚   β”‚   └── HealthStatus.js        # Live service status bar
    β”‚   └── services/
    β”‚       └── api.js                 # Axios client
    └── public/index.html

Setup & Run

Prerequisites

1. Configure Environment

cd backend/space_a
cp .env .env.local

Edit backend/space_a/.env:

GEMINI_API_KEY=your_gemini_api_key
ASSEMBLYAI_API_KEY=your_assemblyai_api_key
API_KEY=hcl-compliance-secret-key
FAISS_INDEX_PATH=faiss_store/index.bin
FAISS_META_PATH=faiss_store/metadata.json

Edit frontend/.env:

REACT_APP_API_URL=http://localhost:8000
REACT_APP_API_KEY=hcl-compliance-secret-key

2. Start Backend

cd backend/space_a
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

API docs available at http://localhost:8000/docs

3. Start Frontend

cd frontend
npm install
npm run dev

Open http://localhost:3000


Quick API Test

# Encode your MP3
B64=$(base64 -w 0 your_call.mp3)

# Analyze
curl -X POST http://localhost:8000/analyze \
  -H "Content-Type: application/json" \
  -H "x-api-key: hcl-compliance-secret-key" \
  -d "{\"language\":\"Tamil\",\"audioFormat\":\"mp3\",\"audioBase64\":\"$B64\"}"

# Search
curl -X POST http://localhost:8000/search \
  -H "Content-Type: application/json" \
  -H "x-api-key: hcl-compliance-secret-key" \
  -d "{\"query\":\"customer refused payment\",\"top_k\":3}"

# Health
curl http://localhost:8000/health

Tech Stack

Layer Technology
Frontend React 18 Β· Vanilla CSS Β· Inter font
API Gateway FastAPI Β· Uvicorn Β· Pydantic v2
Speech-to-Text AssemblyAI (cloud, speaker labels, auto language detection)
Translation Google Gemini 2.0 Flash Lite (Tanglish/Hinglish β†’ English)
NLP Analysis Google Gemini 2.0 Flash Lite (SOP Β· analytics Β· keywords)
Vector Embeddings sentence-transformers/all-MiniLM-L6-v2 (384-dim, normalized)
Vector DB FAISS IndexFlatIP (inner product = cosine similarity)
HTTP Client httpx (async) Β· requests (AssemblyAI polling)

Evaluation Criteria Compliance

Criterion Implementation
API returns 200 OK FastAPI with strict Pydantic response models
Transcript accuracy AssemblyAI universal model + speaker labels + punctuation
SOP correctness Gemini analyzes English translation for accuracy on mixed-language calls
Analytics correctness Strict enum enforcement + post-processing normalization
Keywords extraction 5–10 grounded keywords, validated and padded if needed
JSON format Pydantic enforced β€” any schema violation raises 422
Robustness 3-pass agentic JSON healing + translation fallback to cleaned transcript

Built for HCL-GUVI Hackathon 2026

Call Center Compliance API β€” Space A

AI-powered call center compliance analysis with SOP validation, sentiment analysis, and keyword extraction.

Endpoints

Method Path Description
POST /analyze Full call analysis pipeline
GET /search?q=... Semantic FAISS search
GET /health Uptime check
GET /docs Swagger UI

Required Secrets (set in HF Space Settings β†’ Repository secrets)

Variable Description
API_KEY Your API auth key sent as x-api-key header
GEMINI_API_KEY Google Gemini API key
ASSEMBLYAI_API_KEY AssemblyAI transcription key

Example Request

curl -X POST https://<your-space>.hf.space/analyze \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "language": "Tamil",
    "audioFormat": "mp3",
    "audioBase64": "<base64-encoded-mp3>"
  }'

About

Call Center Compliance with AI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages