AffectFace

Privacy-first emotion detection Chrome extension with LLM integration and emotional competence scoring

Multi-modal AIReal-time ProcessingPrivacy-firstChrome ExtensionTypeScriptMediaPipe

Browser Compatibility

AffectFace has been tested on Chrome browsers and iPhone (Safari) only. Other browsers may experience compatibility issues.

Chrome (Recommended) iPhone Safari

Please Be Considerate

The live app uses AI APIs (OpenAI, Anthropic, Hume AI) which incur costs per request. Please use the app thoughtfully and consider supporting this research.

Support This Research

Overview

AffectFace is a production-ready Chrome extension (Manifest V3) that performs real-time emotion detection using audio and video analysis. It integrates with multiple LLM providers (OpenAI, Anthropic, local endpoints) and provides a comprehensive rubrics-based scoring system for evaluating emotional competence in AI responses.

Multi-modal Detection
  • • Audio prosody analysis (pitch, loudness, tempo)
  • • Facial expression detection via MediaPipe
  • • Weighted fusion of audio, video, and text
  • • Real-time processing at 10 Hz
LLM Integration
  • • OpenAI (GPT-4, GPT-3.5)
  • • Anthropic (Claude 3)
  • • Local HTTP endpoints
  • • Real-time emotion context for queries
Rubrics Scoring
  • • 5 criteria evaluation system
  • • Weighted scoring with customization
  • • CSV export for analysis
  • • Dashboard with statistics
Privacy-First Design
  • • All analysis performed on-device
  • • No raw audio/video sent externally
  • • Explicit consent required
  • • Visible watermark during analysis

Architecture

VBD (Value-Based Development)
Built with strict separation of concerns and modular design

Accessors Layer

Data access layer with CRUD operations for storage management

Engines Layer

Business logic for emotion fusion, classification, and analysis

Managers Layer

Workflow orchestration coordinating multiple engines

Use Cases

Therapists & Counselors

Track emotional patterns in therapy sessions for better outcomes

AI Researchers

Study emotional competence in AI systems and LLM responses

Communication Training

Evaluate communication skills and empathy in professional settings

Mental Health Support

Provide emotion awareness for individuals seeking better self-understanding

Technology Stack

TypeScript 5.3

Language

Vite 5.0

Build Tool

MediaPipe

ML Framework

Web Audio API

Audio Analysis

Multi-Modal Analysis Pipeline

AffectFace analyzes emotions through three parallel streams that converge into a unified emotion vector, providing comprehensive emotional intelligence in real-time.

Audio Prosody Analysis

Real-time voice analysis capturing emotional truth that words can hide.

RMS (Loudness) - Energy level and emotional intensity
Pitch Estimation - Fundamental frequency via autocorrelation
Spectral Centroid - Voice "brightness" and quality
Zero-Crossing Rate - Speaking rate and tempo
Performance: 10 Hz analysis rate (100ms intervals) with minimal CPU overhead
Facial Expression Detection

Advanced facial analysis using MediaPipe Face Landmarker with FACS-based emotion mapping.

53 Distinct Emotions - Comprehensive emotion detection
FACS Blendshapes - Facial Action Coding System mapping
Micro-expressions - Brief involuntary expressions
GPU Acceleration - Hardware-accelerated processing
Performance: 256x256 video downscaling + GPU acceleration = 30 FPS analysis
Text Sentiment Analysis

Linguistic analysis providing explicit emotional content that audio and video might miss.

Lexical Sentiment - Positive/negative word choice
Emotional Keywords - Direct emotion expressions
Linguistic Patterns - Question types and urgency markers
Context Awareness - Semantic understanding

Advanced Capabilities

Emotion Fusion Engine

Intelligent weighted combination of audio, video, and text signals with dynamic adjustment.

  • Default weights: Audio 45%, Video 30%, Text 25%
  • Dynamic weight adjustment based on availability
  • Confidence scoring affects final weights
  • Exponential moving average smoothing
Congruence Detection

Identifies when facial expressions and voice tone disagree - revealing emotional masking or suppression.

  • Smiling + sad voice = Emotional masking
  • Neutral face + anxious voice = Suppressed anxiety
  • Happy face + angry voice = Sarcasm detection
  • Clinical value for therapists and counselors
Privacy Architecture

HIPAA-ready design with on-device processing and zero data transmission.

  • All ML models run locally via WebAssembly
  • Raw audio/video never leaves your device
  • Encrypted storage for API keys
  • Explicit consent with visible watermark
Research & Export

Comprehensive data export and analysis tools for researchers and professionals.

  • CSV export with 12+ data fields
  • Session tracking and longitudinal analysis
  • Emotion trend visualization
  • Rubrics-based scoring dashboard

How It Was Built

VBD Architecture Principles
Built following Value-Based Development with strict separation of concerns

Accessors Layer

Pure data access layer - database-agnostic CRUD operations

  • • No business logic, only data operations
  • • Consistent Result<T> types with error handling
  • • Full TypeScript typing for type safety

Engines Layer

Business logic and domain rules - the intelligence core

  • • Emotion fusion and classification algorithms
  • • Stateless functions for predictability
  • • Single responsibility per engine

Managers Layer

Workflow orchestration - coordinating multiple engines

  • • Complex business workflows
  • • Transaction management
  • • API route coordination
Development Stack
LanguageTypeScript 5.3 (strict mode)
Build ToolVite 5.0
ML FrameworkMediaPipe Face Landmarker
AudioWeb Audio API
VideoCanvas API + getUserMedia
StorageChrome Storage API
Performance Metrics
CPU Usage<5% on modern hardware
Memory<50MB total
Latency<100ms capture to result
Analysis Rate10 Hz (100ms intervals)
Video Processing30 FPS
Code Coverage90% target
Open Source & Research

AffectFace is fully open source (MIT License) to promote transparency, security, and innovation in emotion AI. The codebase includes comprehensive documentation, research findings, and real-world use cases from legal, therapy, and counseling professionals.

3,500+ LinesTypeScript code
8,000+ WordsDocumentation
40+ FilesModular architecture

Real-World Impact

Clinical Psychology

Therapists track emotional patterns over multiple sessions, identifying worsening depression before crisis and helping clients with alexithymia develop emotional awareness.

“This isn't replacing my clinical judgment—it's enhancing it with objective data.”

Academic Counseling

University counselors identify at-risk students during routine advising, enabling early intervention and preventing dropout through timely mental health support.

“Students are really good at hiding distress. AffectFace helps me identify those who need support.”

Healthcare

Primary care physicians improve pain assessment accuracy by detecting when patients under-report due to cultural factors or fear, leading to better pain management.

“When face, voice, and words don't align, I know to probe deeper.”

Research & Education

Researchers study the evolution of emotional intelligence in AI systems, comparing models from GPT-3 to GPT-4o to understand how affective computing capabilities have advanced.

“AffectFace enables longitudinal studies of AI emotional competence that weren't possible before.”