Full-stack live “Sentiment Aura” demo using React + FastAPI with Deepgram Realtime and OpenRouter.
- Backend (FastAPI)
- Python 3.11+
- Create a virtualenv and install deps:
pip install -r backend/requirements.txt
- Set env (create
.envinbackend/directory):OPENROUTER_API_KEY=<your_key>DEEPGRAM_API_KEY=<your_key>ALLOWED_ORIGINS=http://localhost:5173- Optional:
OPENROUTER_MODEL=openai/gpt-4o-miniOPENROUTER_BASE_URL=https://openrouter.ai/api/v1REQUEST_TIMEOUT_SECONDS=12.0
- Run:
uvicorn app.main:app --reload --port 8000 --app-dir backend
- Frontend (React + Vite + TS)
cd frontendnpm install- Create
.env.local:VITE_BACKEND_URL=http://localhost:8000VITE_DEEPGRAM_API_KEY=<your_key>VITE_DEEPGRAM_WSS=wss://api.deepgram.com/v1/listen?model=nova-2&encoding=linear16&sample_rate=16000
npm run devthen openhttp://localhost:5173
- Frontend streams mic audio to Deepgram Realtime over WebSocket (16k PCM).
- Finalized transcript segments are sent to FastAPI
/process_text. - Backend calls OpenRouter (provider-agnostic) to extract sentiment score/label and keywords.
- Visualization (p5.js) maps sentiment to color and energy; keywords cause subtle flares.
- Backend:
uvicorn app.main:app --reload --port 8000 --app-dir backend - Frontend:
npm run dev(infrontend)