Adarsh Puthane
AI Emotion Detection App
PythonIBM WatsonNLPHTMLFlask

AI Emotion Detection App

Turn any sentence into a live emotional fingerprint.

Overview

Emotion-aware text analysis has clear applications in customer support triage, content moderation, and mental wellness monitoring. Building a bespoke NLP model from scratch is beyond most small teams. This project wires IBM Watson's production-grade NLP Emotion service into a clean web interface, abstracting the API complexity and surfacing results in an intuitive, animated breakdown.

The Problem

Fine-tuning a multi-class emotion model requires large labelled datasets and significant compute. Off-the-shelf sentiment APIs only return positive/negative polarity — too coarse for real-world use. Teams need a quick integration path to a production-quality emotion classifier without the ML infrastructure overhead.

The Solution

Built a thin Flask backend that securely holds the Watson API credentials, validates and sanitises incoming text, handles rate-limit retries, and proxies calls to IBM Watson NLP. The frontend sends text asynchronously and renders the five emotion scores as animated progress bars, highlighting the dominant emotion in a contrasting accent colour.

Key Features

  • Five-emotion classification (joy, sadness, anger, fear, disgust) via IBM Watson NLP
  • Animated progress bars filling in sequence from dominant to least dominant emotion
  • Dominant emotion card with contextual colour coding and emoji indicator
  • Input sanitisation — HTML stripping, XSS prevention, 500-character cap
  • Exponential back-off on Watson 429 rate-limit responses
  • User-friendly error states for API failures and empty submissions
  • Accessible colour contrast ratios across all emotion colour themes

Challenges & Learnings

IBM Watson's API enforces rate limits that surfaced during rapid successive submissions from multiple test users. Implemented an exponential back-off strategy with a maximum of 3 retries before surfacing a user-friendly error. Input sanitisation was a priority security concern — user-provided strings go into an external API call, so added HTML entity stripping, length enforcement, and UTF-8 normalisation before forwarding. Making probability float outputs (0.0–1.0) feel intuitive required UX iteration: settled on sequential bar-fill animations that help users read the relative magnitudes rather than raw numbers.

Tech Stack

Backend

PythonFlaskIBM Watson NLP SDKrequests

AI / NLP

IBM Watson Natural Language UnderstandingEmotion Analysis feature

Frontend

HTML5CSS3Vanilla JavaScript

Security

Input sanitisationCORS headersAPI key server-side storage