Real-time emotion visualization powered by AI and Perlin noise flow fields.
An interactive web application that captures live speech, transcribes it in real-time, analyzes sentiment using AI, and visualizes emotions through generative Perlin noise art. The visualization dynamically responds to emotional content - colors shift from cool blues (negative) to warm oranges (positive), and particle motion intensifies with emotional intensity.
https://drive.google.com/file/d/1XIJFyOm7YMVTyYcAi8C3IddCOokCrs_Y/view?usp=sharing
- π€ Real-time Speech Transcription - Live audio capture with Deepgram's Nova-3 model
- π€ AI Sentiment Analysis - Groq LLM analyzes emotional tone and extracts keywords
- π¨ Dynamic Perlin Noise Visualization - 10,000 particles flowing in organic patterns
- π·οΈ Animated Keywords - Smooth fade-in/fade-out transitions
- π Auto-reconnection - Handles network drops gracefully
- π Auto-scrolling Transcript - Clean, readable conversation history
- React - UI framework
- p5.js - Perlin noise visualization
- Web Audio API - Microphone access via AudioWorklet
- WebSocket - Real-time Deepgram connection
- Axios - HTTP client for backend API
- FastAPI - Python web framework
- Uvicorn - ASGI server
- httpx - Async HTTP client for LLM API
- Deepgram - Speech-to-text transcription (Nova-3 model)
- Groq - LLM sentiment analysis (Llama 3.1)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USER SPEAKS β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β REACT FRONTEND (localhost:3000) β
β β
β 1. AudioWorklet captures mic (16kHz PCM) β
β 2. WebSocket streams audio β Deepgram β
β 3. Receives transcript (interim + final) β
β 4. On final β POST to backend β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ HTTP POST /process_text
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FASTAPI BACKEND (localhost:8000) β
β β
β 5. Receives text β
β 6. Constructs prompt for LLM β
β 7. Calls Groq API β
β 8. Returns JSON: {sentiment_score, type, β
β intensity, keywords} β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ JSON Response
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β REACT FRONTEND β
β β
β 9. Updates state (sentiment, keywords) β
β 10. React re-renders: β
β - Perlin noise shifts color/speed β
β - Keywords fade in/out β
β - Transcript updates β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Negative (-1.0 to -0.3): Deep blue β Purple (cool tones)
- Neutral (-0.3 to 0.3): Purple β Pink (transitional)
- Positive (0.3 to 1.0): Orange β Yellow (warm tones)
- Intensity (0 to 1): Controls particle speed and noise scale
- High intensity: Fast, chaotic, energetic flow
- Low intensity: Slow, calm, meditative movement
- Node.js 16+ and npm
- Python 3.9+
- Deepgram API key (Get free $200 credits)
- Groq API key (Free account)
# Navigate to backend directory
cd backend
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create .env file with your API keys
cp .env.example .env
# Edit .env and add: GROQ_API_KEY=your_groq_key_here
# Start server
uvicorn main:app --reloadBackend will run on http://localhost:8000
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Create .env file with your API key
cp .env.example .env
# Edit .env and add: REACT_APP_DEEPGRAM_API_KEY=your_deepgram_key_here
# Start development server
npm startFrontend will open at http://localhost:3000
- Click "Start Recording"
- Allow microphone access when prompted
- Speak naturally - try different emotional tones:
- Positive: "I'm so excited about this amazing project!"
- Negative: "This is really frustrating and difficult."
- Neutral: "Let me think about the technical details."
- Watch the visualization respond to your emotions
- Click "Stop" when finished
sentiment-aura/
βββ backend/
β βββ main.py # FastAPI app with sentiment endpoint
β βββ requirements.txt # Python dependencies
β βββ .env.example # Environment variable template
β
βββ frontend/
βββ src/
β βββ App.js # Main React component
β βββ components/
β β βββ AuraVisualization.js # Perlin noise p5.js canvas
β β βββ KeywordsDisplay.js # Animated keyword tags
β β βββ TranscriptDisplay.js # Auto-scrolling transcript
β βββ utils/
β βββ audioCapture.js # AudioWorklet microphone capture
β βββ deepgramService.js # WebSocket transcription
βββ package.json
βββ .env.example
- Uses AudioWorklet (modern replacement for deprecated ScriptProcessor)
- Captures at 16kHz sample rate (Deepgram requirement)
- Converts Float32 audio to Int16 PCM format
- Streams to Deepgram via WebSocket
- Backend constructs structured prompt for Groq LLM
- Requests JSON response with sentiment score (-1 to 1), type, intensity, and keywords
- Error handling for timeout, parsing failures, and API errors
- 10,000 particles in Perlin noise flow field
- Smooth transitions via
lerp()interpolation - Particles respawn periodically to prevent clustering
- HSB color mode for smooth hue transitions
- Microphone denied: Clear instructions to enable in browser settings
- Backend offline: Graceful degradation - transcript still works
- Network drop: Auto-reconnects up to 3 times with user feedback
- API failures: Specific error messages guide user to fix issues
- Sentiment analysis has ~2-3 second delay (LLM processing time)
- Requires modern browser with AudioWorklet support (Chrome/Edge recommended)
- Audio during network disconnection is lost (cannot buffer indefinitely)
- Best experienced on desktop/laptop
- Sentiment history graph over time
- Multiple visualization modes (flow field, particles, waves)
- Export visualization as video
- Multi-language support
- Custom color palettes
Run both servers concurrently:
# Terminal 1 - Backend
cd backend && source venv/bin/activate && uvicorn main:app --reload
# Terminal 2 - Frontend
cd frontend && npm start- Perlin noise flow field inspired by Sighack
- Built as take-home assignment for Memory Machines
Author: Ruoyu Li
Date: November 2024