Skip to content

About

AI-powered REST API that analyzes call center recordings for SOP compliance using Gemini 2.5 Flash's native multimodal audio understanding — supports Tamil, Hindi & English in under 15 seconds.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

📞 Call Center Compliance API

Track 3 — HCL GUVI BuildBridge Intern Hiring Hackathon 2026 A production-grade REST API that analyzes call center recordings for SOP compliance using Google Gemini 2.5 Flash's native multimodal audio understanding.

Live Endpoint: https://aarushg025-call-center-compliance.hf.space/api/call-analytics


📖 Description

Call centers handle thousands of customer interactions daily, making it impossible for quality teams to manually audit every call. This API automates the entire compliance auditing process:

  1. Accepts a Base64-encoded MP3 audio recording via a REST endpoint
  2. Compresses the audio using FFmpeg for optimal processing speed
  3. Sends the audio directly to Google Gemini 2.5 Flash in a single multimodal request
  4. Gemini natively listens to the audio, transcribes it (supporting Tamil/Tanglish, Hindi/Hinglish, and English), and simultaneously evaluates SOP compliance
  5. Returns a fully structured JSON report with transcript, compliance scores, sentiment analysis, payment analytics, and keywords — all in under 15 seconds

🏗️ Architecture Overview

                         POST /api/call-analytics
                         (Base64 MP3 + language)
                                │
                                ▼
┌──────────────────────────────────────────────────────────┐
│                   FastAPI Server (main.py)                │
│                                                          │
│  1. API Key Authentication (x-api-key header)            │
│  2. Base64 Decode → Raw Audio Bytes                      │
│  3. Route to Analyzer                                    │
│  4. Resilient Enum Mapping (AI output → strict schema)   │
│  5. Return validated JSON response                       │
└───────────────────────┬──────────────────────────────────┘
                        │
                        ▼
┌──────────────────────────────────────────────────────────┐
│              Analyzer Module (analyzer.py)                │
│                                                          │
│  Step 1: FFmpeg Audio Compression                        │
│          (Mono, 16kHz, 32kbps → ~50KB)                   │
│                                                          │
│  Step 2: Single Gemini 2.5 Flash Multimodal Call         │
│          - Native audio understanding (no separate STT)  │
│          - Thinking disabled (thinking_budget=0)         │
│          - Returns: transcript + analysis in one shot    │
└───────────────────────┬──────────────────────────────────┘
                        │
                        ▼ (Background Task — non-blocking)
┌──────────────────────────────────────────────────────────┐
│            Vector Store (vector_store.py)                 │
│                                                          │
│  ChromaDB indexes transcripts + summaries as embeddings  │
│  for downstream semantic search and retrieval            │
└──────────────────────────────────────────────────────────┘

Key Design Decision: Instead of the traditional 3-step pipeline (Transcribe → Analyze → Format), this system uses a single multimodal API call where Gemini processes raw audio directly. This eliminates intermediate transcription errors (especially for Tamil/Tanglish) and reduces total latency by ~60%.


🛠️ Tech Stack

Layer Technology Purpose
Language Python 3.10 Core application runtime
Web Framework FastAPI Async REST API with auto-generated OpenAPI docs
Data Validation Pydantic v2 Strict schema enforcement with enum validation
Primary AI Google Gemini 2.5 Flash Native multimodal audio transcription + NLP analysis
Backup STT Groq Whisper Large V3 Turbo Fallback speech-to-text (kept for resilience)
Audio Processing FFmpeg Audio compression (5MB → 50KB) for faster inference
Vector Database ChromaDB Semantic indexing of transcripts for retrieval
Containerization Docker Reproducible deployment on Hugging Face Spaces
Hosting Hugging Face Spaces Free cloud deployment with Docker SDK support

🤖 AI Tools Used

Full disclosure of all AI assistance as required by hackathon rules.

AI Models in Production Code

AI Tool Version/Model How It's Used
Google Gemini 2.5 Flash gemini-2.5-flash Primary engine — processes raw audio multimodally to produce transcripts, SOP compliance analysis, sentiment detection, payment analytics, and keyword extraction in a single API call. Thinking mode disabled (thinking_budget=0) for speed optimization.
Groq Whisper whisper-large-v3-turbo Fallback speech-to-text transcription via Groq's hosted inference API. Used only when Gemini is unavailable.
ChromaDB Embeddings Default all-MiniLM-L6-v2 Generates vector embeddings for semantic indexing of call transcripts.

AI Tools Used During Development

AI Tool How It Helped
Antigravity (AI Coding Assistant) Assisted with code architecture design, debugging deployment issues and optimizing Gemini API integration.

📋 API Reference

Endpoint

POST /api/call-analytics

Headers

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

Request Body

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

Response

{
  "status": "success",
  "language": "Tamil",
  "transcript": "Vanakkam sir, en peyar Raj...",
  "summary": "Agent called customer about outstanding payment...",
  "sop_validation": {
    "greeting": true,
    "identification": true,
    "problemStatement": true,
    "solutionOffering": true,
    "closing": false,
    "complianceScore": 0.8,
    "adherenceStatus": "FOLLOWED",
    "explanation": "Agent followed 4 of 5 SOP steps."
  },
  "analytics": {
    "paymentPreference": "EMI",
    "rejectionReason": "BUDGET_CONSTRAINTS",
    "sentiment": "Neutral"
  },
  "keywords": ["payment", "EMI", "outstanding", "due date"]
}

⚙️ Setup Instructions

Prerequisites

  • Python 3.10+
  • FFmpeg installed (apt install ffmpeg or choco install ffmpeg on Windows)
  • Google Gemini API Key (Get one here)

1. Clone the Repository

git clone https://github.com/aarushg025/call-center-compliance.git
cd call-center-compliance

2. Create Virtual Environment

python -m venv .venv

# Windows
.venv\Scripts\activate

# Linux/Mac
source .venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Configure Environment Variables

Create a .env file in the project root:

GEMINI_API_KEY=your_gemini_api_key_here
GROQ_API_KEY=your_groq_api_key_here
API_SECRET_KEY=sk_track3_25092007

5. Run the Application

uvicorn src.main:app --host 0.0.0.0 --port 8000 --reload

The API will be available at http://localhost:8000. Interactive docs at http://localhost:8000/docs.

Docker Deployment (Hugging Face Spaces)

The app is pre-configured for Hugging Face Spaces with the included Dockerfile. Simply push to a Space with Docker SDK selected.


📁 Project Structure

call-center-compliance/
├── src/
│   ├── main.py            # FastAPI server, endpoint routing, enum mapping
│   ├── analyzer.py         # Gemini multimodal audio analysis + FFmpeg compression
│   ├── models.py           # Pydantic request/response schemas and enums
│   ├── transcriber.py      # Groq Whisper fallback transcription
│   ├── vector_store.py     # ChromaDB semantic indexing
│   └── config.py           # Environment configuration
├── sop.json                # SOP rule definitions (5 compliance rules)
├── Dockerfile              # Container build instructions for HF Spaces
├── requirements.txt        # Python dependencies
├── .env.example            # Template for environment variables
├── test_api.py             # API testing script
└── README.md               # This file

⚠️ Known Limitations

  1. Gemini Rate Limits: The free-tier Gemini API has rate limits (15 RPM, 1M tokens/day). Under heavy concurrent load, requests may be throttled. A paid API key removes this limitation.

  2. Audio Length: Audio files longer than 2 minutes are trimmed during FFmpeg compression. Very long calls may lose context from the latter portion.

  3. Tamil Accuracy: While Gemini 2.5 Flash handles Tamil/Tanglish significantly better than traditional STT models, highly colloquial or dialect-heavy Tamil may still have transcription inaccuracies.

  4. Single-Speaker Diarization: The system does not perform speaker diarization (separating Agent vs. Customer voices). The transcript is a continuous text without speaker labels.

  5. Payment Analytics Defaults: If the call does not discuss payment topics, the system defaults to DOWN_PAYMENT for paymentPreference and NONE for rejectionReason, as these fields are required by the schema.

  6. Cold Start Delay: On Hugging Face Spaces free tier, the container may go to sleep after inactivity. The first request after a cold start may take an additional 30-60 seconds while the container boots.

  7. No Persistent Storage: ChromaDB data is stored in-container and resets on each deployment. For production use, an external database would be required.


👤 Author

Aarush Goel Email: aarushgoel025@gmail.com

Linkedin: Aarush Goel

Github: github.com/aarushg025


📄 License

This project was built for Track 3 of the HCL GUVI BuildBridge Intern Hiring Hackathon 2026.

About

AI-powered REST API that analyzes call center recordings for SOP compliance using Gemini 2.5 Flash's native multimodal audio understanding — supports Tamil, Hindi & English in under 15 seconds.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages