Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🍳 CookCam β€” Live AI Cooking Coach

Real-time AI cooking assistant that sees your kitchen through your webcam and guides you step-by-step through natural voice conversation.

Built with Gemini Live API for multimodal real-time interaction (vision + audio).

Category: Live Agents πŸ—£οΈ Gemini Cloud Run


✨ Features

  • πŸŽ₯ Ingredient Scanner β€” Point your camera, AI identifies ingredients in real-time
  • πŸ—£οΈ Voice Interaction β€” Natural conversation with interruption support
  • πŸ“‹ Recipe Suggestions β€” Get recipe ideas based on visible ingredients
  • πŸ‘¨β€πŸ³ Live Cooking Guide β€” Step-by-step voice instructions as you cook
  • πŸ‘οΈ Real-time Feedback β€” "Those look perfectly golden, time to flip!"
  • πŸ”„ Substitutions β€” "I don't have cumin" β†’ suggests alternatives
  • ⚠️ Safety Alerts β€” Proactive food safety warnings

πŸ—οΈ Architecture

CookCam Architecture Diagram

Browser (Webcam + Mic)
    ↕ WebSocket (binary PCM audio + base64 JPEG video frames)
FastAPI Backend (server.py)
    ↕ Gemini Live API (send_realtime_input / receive)
Gemini 2.5 Flash Native Audio
    β†’ Audio responses + Text + Function Calls (tool use)
        ↕
Cloud Firestore (recipes + sessions persistence)

Key data flows:

  • Browser β†’ Backend β†’ Gemini: Webcam frames (768Γ—768 JPEG, 1 FPS) + microphone audio (16kHz PCM) streamed over WebSocket
  • Gemini β†’ Backend β†’ Browser: Voice responses (24kHz PCM) + text + function calls (timers, recipes, checklists) routed back in real time
  • Backend ↔ Firestore: Saved recipes and session tokens persisted (with automatic in-memory fallback)
  • Function Calling: Gemini proactively invokes 6 tools β†’ backend executes them β†’ UI updates sent to browser β†’ results returned to Gemini

πŸš€ Quick Start

Prerequisites

Local Setup

  1. Clone and navigate:

    cd ntt
  2. Install dependencies:

    pip install -r requirements.txt
  3. Set your API key:

    # Copy the template
    cp .env.example .env
    
    # Edit .env and add your key
    GEMINI_API_KEY=your-actual-api-key
  4. Run the server:

    python server.py
  5. Open in Chrome:

    http://localhost:8080
    
  6. Allow camera & microphone when prompted, then click Start Session!

Google Cloud Run Deployment

Option A: One-command deploy script (deploy.sh)

# Make executable (first time only)
chmod +x deploy.sh

# Deploy with defaults
./deploy.sh

# Or override project/region
./deploy.sh --project YOUR_PROJECT_ID --region us-central1

The script automatically:

  • Loads GEMINI_API_KEY from .env
  • Enables required GCP APIs (Cloud Run, Cloud Build, Artifact Registry)
  • Builds the Docker image from source
  • Deploys to Cloud Run with optimized settings (3600s timeout for WebSockets, 512Mi memory)
  • Prints the live HTTPS URL

Option B: CI/CD with Cloud Build (cloudbuild.yaml)

Automated pipeline that runs on every push to main:

# One-time: create the trigger
gcloud builds triggers create github \
  --repo-name=ntt --repo-owner=YOUR_GITHUB_USER \
  --branch-pattern="^main$" \
  --build-config=cloudbuild.yaml

The pipeline (defined in cloudbuild.yaml):

  1. Builds the Docker image and tags it with the commit SHA
  2. Pushes to Artifact Registry
  3. Deploys to Cloud Run with all production settings

Option C: Manual deploy

gcloud config set project YOUR_PROJECT_ID

gcloud run deploy cookcam \
  --source . \
  --port 8080 \
  --allow-unauthenticated \
  --set-env-vars GEMINI_API_KEY=your-key \
  --region us-central1 \
  --timeout 3600

Firestore Setup (Optional)

Recipes and sessions persist automatically on Cloud Run (Firestore is auto-detected).

For local development with Firestore:

  1. Create a Firestore database in your GCP project (Native mode)
  2. Set credentials:
    export GOOGLE_CLOUD_PROJECT=your-project-id
    export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

To skip Firestore and use in-memory storage, set:

export FIRESTORE_DISABLED=true

πŸ› οΈ Tech Stack

Component Technology
AI Model Gemini 2.5 Flash Native Audio (Live API)
Backend Python, FastAPI, WebSockets
Frontend Vanilla HTML/CSS/JS, Web Audio API, AudioWorklet
Cloud Google Cloud Run
Storage Cloud Firestore (with in-memory fallback)
SDK Google GenAI Python SDK

πŸ“ Project Structure

ntt/
β”œβ”€β”€ server.py                 # FastAPI backend + Gemini Live API proxy
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ Dockerfile                # Cloud Run container
β”œβ”€β”€ cloudbuild.yaml           # CI/CD pipeline β€” automated build & deploy
β”œβ”€β”€ deploy.sh                 # One-command deploy script
β”œβ”€β”€ .env.example              # Environment template
β”œβ”€β”€ README.md
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ gemini_client.py      # Gemini Live API WebSocket client
β”‚   β”œβ”€β”€ tools.py              # Gemini function-call tool declarations & handlers
β”‚   β”œβ”€β”€ firestore_client.py   # Firestore persistence (recipes, sessions)
β”‚   β”œβ”€β”€ rate_limiter.py       # Token-bucket rate limiter
β”‚   └── session_store.py      # Session management (Firestore-backed)
β”œβ”€β”€ core/
β”‚   └── config.py             # API keys, model config, system prompt
β”œβ”€β”€ utils/
β”‚   └── logger.py             # Structured logging
└── static/
    β”œβ”€β”€ index.html            # Main web page
    β”œβ”€β”€ css/styles.css        # Premium dark theme
    β”œβ”€β”€ js/app.js             # Frontend logic (WebSocket, webcam, audio)
    └── audio-processor.js    # AudioWorklet for PCM mic capture

🎯 How It Works

  1. Camera captures video at 768Γ—768 JPEG, sent at 1 FPS to Gemini
  2. Microphone captures audio, downsampled to 16kHz PCM via AudioWorklet
  3. FastAPI proxies both streams to Gemini Live API via WebSocket
  4. Gemini processes vision + audio, returns voice responses at 24kHz
  5. Browser plays AI audio seamlessly with scheduled buffer playback
  6. Interruption: speak while AI is talking β†’ it stops and responds to you

οΏ½ Features to Add

πŸ”§ Core Functionality

  • Tool Calling / Function Calling β€” Wire up Gemini tool use (TOOLS_LIST in api/tools.py) for structured actions like setting timers, saving recipes, and unit conversions
  • Timer System β€” Voice-activated cooking timers ("Set a timer for 12 minutes") with audio alerts and on-screen countdown
  • Recipe Memory & History β€” Save completed recipes and session transcripts so users can revisit past cooks
  • Multi-Step Recipe Tracking β€” Visual step indicator on the UI showing current step, next step, and overall progress
  • Ingredient Checklist β€” Auto-generate an ingredient list from the chosen recipe with tap-to-check-off support

🎨 UI / UX Improvements

  • Dark/Light Theme Toggle β€” Add a theme switcher in the top bar
  • Text Chat Input β€” Allow users to type messages in addition to voice (useful in noisy kitchens)
  • Recipe Card Display β€” Render structured recipe cards (ingredients, steps, servings, time) in the activity panel
  • Responsive Tablet Layout β€” Optimize the two-panel layout for tablet-sized screens
  • Accessibility (a11y) β€” ARIA labels, keyboard navigation, screen reader support for all controls
  • Loading / Skeleton States β€” Improve perceived performance with skeleton UI while connecting

πŸ€– AI & Intelligence

  • Nutritional Info β€” Ask "How many calories is this?" and get per-serving nutritional estimates
  • Dietary Preference Profiles β€” Let users set preferences (vegetarian, gluten-free, nut allergy) so suggestions are always relevant
  • Skill-Level Adaptation β€” Detect beginner vs. experienced cooks and adjust instruction verbosity
  • Multi-Language Support β€” Respond in the user's preferred language (leverage Gemini's multilingual capabilities)
  • Plating & Presentation Tips β€” AI suggests plating ideas based on what it sees

πŸ“‘ Backend & Infrastructure

  • Session Persistence β€” Store session state so users can reconnect after a dropped connection
  • Rate Limiting & Auth β€” Add API key rotation, per-user rate limits, and optional user authentication
  • Error Recovery & Reconnect β€” Auto-reconnect WebSocket with exponential backoff on connection drops
  • Logging Dashboard β€” Structured logging with request tracing; optional integration with Cloud Logging
  • Health Check Endpoint β€” Add /health route for Cloud Run liveness/readiness probes

πŸ“± Platform & Integrations

  • PWA Support β€” Add a web app manifest and service worker so CookCam can be installed on mobile home screens
  • Share Recipe β€” Generate a shareable link or image card of the recipe cooked
  • Grocery List Export β€” Export missing ingredients to a shopping list (Google Keep, Apple Reminders, etc.)
  • Smart Display Mode β€” A hands-free, large-font "kitchen display" mode optimized for viewing from a distance

πŸ§ͺ Testing & Quality

  • Unit Tests β€” Add pytest tests for GeminiLiveClient, config loading, and tool functions
  • Frontend Tests β€” Basic integration tests for WebSocket connection, audio pipeline, and UI state
  • CI/CD Pipeline β€” GitHub Actions workflow for linting, testing, and auto-deploying to Cloud Run
  • Load Testing β€” Verify concurrent WebSocket session limits and Gemini API quota handling

πŸ“œ License

Built for the Gemini Live Hackathon 2026 πŸ†

πŸ”— GitHub: github.com/shafisma/cookcam

About

Real-time AI cooking assistant that sees your kitchen through your webcam and guides you step-by-step through natural voice conversation.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages