Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽค Sentiment Aura

An AI-powered real-time sentiment analysis application that visualizes emotions through beautiful Perlin noise animations. Speak into your microphone and watch as your words transform into flowing, emotion-driven visual art.

๐ŸŒ Live Demo

โœจ Features

  • ๐ŸŽ™๏ธ Real-time Speech Transcription - Instant audio-to-text using Deepgram API
  • ๐Ÿค– AI Sentiment Analysis - Powered by Claude Sonnet 4 for emotion detection
  • ๐ŸŒŠ Perlin Noise Visualization - Beautiful, organic animations that react to emotions
  • ๐ŸŽจ Emotion-Specific Behaviors - Each emotion has unique colors, speeds, and particle movements
  • ๐Ÿ“Š Live Sentiment Tracking - Real-time sentiment score (0-100%) and keyword extraction
  • ๐Ÿ’ฌ Live Transcript Display - See your words appear in real-time

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React - UI framework
  • react-p5 - Creative coding for Perlin noise visualization
  • Web Audio API - Microphone capture and audio processing
  • WebSockets - Real-time communication with Deepgram
  • Vercel - Deployment platform

Backend

  • FastAPI (Python) - High-performance API framework
  • Anthropic Claude API - AI-powered sentiment analysis
  • Pydantic - Data validation
  • Render - Backend hosting

External APIs

  • Deepgram - Real-time speech-to-text transcription
  • Claude Sonnet 4 - Natural language understanding and sentiment analysis

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         WebSocket          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Browser   โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€> โ”‚   Deepgram   โ”‚
โ”‚  (React)    โ”‚ <โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚     API      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      Transcription         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”‚ HTTP POST /process_text
       โ”‚ (final transcript)
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   FastAPI   โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€> โ”‚   Claude     โ”‚
โ”‚   Backend   โ”‚ <โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚     API      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    Sentiment Analysis      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”‚ JSON Response
       โ”‚ {sentiment, emotion, keywords}
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Perlin Noiseโ”‚
โ”‚ Visualizationโ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Local Development Setup

Prerequisites

Backend Setup

# Navigate to backend folder
cd backend

# Create virtual environment
python3 -m venv venv

# Activate virtual environment
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Create .env file
cat > .env << EOF
ANTHROPIC_API_KEY=your_anthropic_key_here
DEEPGRAM_API_KEY=your_deepgram_key_here
EOF

# Start the server
uvicorn main:app --reload --port 8000

Backend will run at: http://localhost:8000

Frontend Setup

# Navigate to frontend folder
cd frontend

# Install dependencies
npm install

# Create .env.local file
cat > .env.local << EOF
REACT_APP_BACKEND_URL=http://localhost:8000
REACT_APP_DEEPGRAM_API_KEY=your_deepgram_key_here
EOF

# Start development server
npm start

Frontend will run at: http://localhost:3000

๐Ÿ“ฆ Deployment

Deploy Backend to Render

  1. Push code to GitHub
  2. Go to Render Dashboard
  3. Create new Web Service
  4. Connect your repository
  5. Configure:
    • Root Directory: backend
    • Build Command: pip install -r requirements.txt
    • Start Command: uvicorn main:app --host 0.0.0.0 --port $PORT
  6. Add environment variables:
    • ANTHROPIC_API_KEY
    • DEEPGRAM_API_KEY

Deploy Frontend to Vercel

  1. Go to Vercel Dashboard
  2. Import your GitHub repository
  3. Configure:
    • Framework Preset: Create React App
    • Root Directory: frontend
    • Build Command: npm run build
  4. Add environment variables:
    • REACT_APP_BACKEND_URL: Your Render backend URL
    • REACT_APP_DEEPGRAM_API_KEY: Your Deepgram key
  5. Deploy!

๐ŸŽฎ Usage

  1. Open the app in your browser
  2. Click "Start Recording" button
  3. Allow microphone access when prompted
  4. Speak clearly into your microphone
  5. Watch the magic happen:
    • Your words appear as live transcript
    • Background changes color based on emotion
    • Particle speed reflects sentiment intensity
    • Keywords are extracted and displayed

Emotion Examples

  • ๐Ÿ˜Š Happy: "I'm so happy and grateful today!"

    • Bright yellow/gold particles, medium-fast movement
  • ๐Ÿคฉ Excited: "This is amazing! I'm so excited!"

    • Hot pink/magenta, fast chaotic sparkles
  • ๐Ÿ˜ข Sad: "I feel sad and lonely"

    • Deep blue, slow drifting particles
  • ๐Ÿ˜  Angry: "I'm really frustrated and angry!"

    • Pulsing red background, aggressive movement
  • ๐Ÿ˜Œ Calm: "I feel peaceful and calm"

    • Smooth cyan/aqua, gentle floating

๐Ÿ“ Project Structure

sentiment-aura/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ main.py              # FastAPI application
โ”‚   โ”œโ”€โ”€ requirements.txt     # Python dependencies
โ”‚   โ””โ”€โ”€ .env                 # Environment variables (not in repo)
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ App.js           # Main component
โ”‚   โ”‚   โ”œโ”€โ”€ AudioCapture.js  # Microphone & Deepgram integration
โ”‚   โ”‚   โ””โ”€โ”€ AuraVisualization.js  # p5.js Perlin noise visualization
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ .env.production      # Production environment variables
โ”‚
โ”œโ”€โ”€ .gitignore
โ””โ”€โ”€ README.md

๐Ÿ”Œ API Endpoints

GET /

Health check endpoint

Response:

{
  "message": "Sentiment Aura Backend Running!"
}

POST /process_text

Analyze sentiment and extract keywords from text

Request:

{
  "text": "I am so happy and excited!"
}

Response:

{
  "sentiment": 0.9,
  "emotion": "excited",
  "keywords": ["happy", "excited"]
}

๐ŸŽจ Visualization Details

The Perlin noise visualization uses organic, flowing particle systems that respond to emotional data:

  • Color Hue: Determined by emotion type
  • Saturation & Brightness: Mapped to sentiment score (0-1)
  • Particle Speed: Higher sentiment = faster movement
  • Noise Scale: Controls smoothness (calm = very smooth, angry = chaotic)
  • Connections: Lines between nearby particles create flowing patterns

Emotion-Specific Parameters

Emotion Color Speed Behavior
Happy Yellow/Gold Medium-Fast Sparkles
Excited Pink/Magenta Very Fast Chaotic sparkles
Sad Deep Blue Slow Heavy drift
Angry Red Fast Pulsing, aggressive
Calm Cyan/Aqua Very Slow Smooth floating
Neutral Muted Green Medium Balanced flow

๐Ÿ› Troubleshooting

Microphone not working

  • Ensure you're using HTTPS or localhost
  • Check browser permissions for microphone access
  • Try a different browser (Chrome recommended)

CORS errors

  • Verify backend CORS settings include your frontend URL
  • Check that backend is running and accessible

Sentiment not updating

  • Check browser console for errors
  • Verify backend environment variables are set
  • Test backend endpoint directly with curl

Backend spinning down (Render free tier)

  • First request after inactivity takes 30-60 seconds
  • Subsequent requests are fast

๐Ÿ“ License

MIT License - feel free to use this project for learning or personal projects!

๐Ÿ™ Acknowledgments

  • Deepgram - Real-time speech transcription
  • Anthropic - Claude AI for sentiment analysis
  • p5.js - Creative coding framework
  • Memory Machines - Project inspiration

๐Ÿ‘จโ€๐Ÿ’ป Author

Archit Gupta


โญ Star this repo if you found it helpful!

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages