Skip to content

oleksandr-g-rock/Calorie-Counter-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Calorie AI Logo

πŸ₯— Calorie-Counter-AI

Your Smart Nutrition Assistant powered by Vision & Voice AI

Python Aiogram Docker OpenRouter License


πŸš€ The Mission

Stop guessing macros or manually logging food. Calorie-Counter-AI is a high-performance Telegram bot that "looks" at your food and tells you exactly what's on the plate.

Built with Aiogram 3.x, it combines Vision Models (like Gemini 2.0 Flash) with Whisper Audio Transcription to act as your personal nutritionist.

🎯 Why this bot?

Unlike rigid apps, this is a conversation.

  1. See: Snap a photo, and the AI estimates volume, weight, and calories using 3D logic.
  2. Hear: Send a voice note to describe ingredients or ask for advice.
  3. Chat: Ask general nutrition questions ("Is this healthy?") in plain text.

✨ Superpowers

  • πŸ‘οΈ Visual 3D Analysis: Uses advanced Vision AI to estimate food volume based on reference objects (cutlery, plates).
  • πŸ—£οΈ Voice-First: Integrated with self-hosted Whisper to transcribe your meal descriptions or questions instantly.
  • 🧠 Context Aware: Knows the current date and time to give relevant advice (e.g., "It's late for a heavy meal").
  • 🌍 Bilingual: Automatically detects English or Ukrainian input and responds in the correct language.
  • ⚑ Webhook Powered: Zero-latency response using Aiohttp architecture.

πŸ› οΈ Quick Start (Docker)

The project is fully containerized. You can run it in seconds.

1. Build the Image

docker build -t calorie-bot .

2. Run the Container

Replace the variables with your actual data.

docker run -d \
  --name calorie-bot \
  -p 8000:8000 \
  -e TELEGRAM_TOKEN="123456:ABC-DEF1234ghIkl..." \
  -e BASE_URL="https://your-public-domain.com" \
  -e WHISPER_API_URL="http://whisper-service:9000/v1" \
  -e OPENROUTER_API_URL="sk-or-v1-..." \
  -e MODEL_NAME="google/gemini-2.0-flash-exp" \
  -e PORT=8000 \
  calorie-bot

βš™οΈ Configuration

Control the bot using Environment Variables.

Variable Required Description
TELEGRAM_TOKEN βœ… Your bot token from @BotFather.
BASE_URL βœ… Your public HTTPS domain (SSL required for Webhooks).
OPENROUTER_API_KEY βœ… API Key from OpenRouter (to access LLMs).
WHISPER_API_URL βœ… Address of your Whisper backend (internal or cloud).
MODEL_NAME ❌ AI Model to use (Default: google/gemini-2.0-flash-exp).
PORT ❌ Internal app port (Default: 8000).
TOPIC_ID ❌ Telegram Forum Topic ID. When set, the bot only responds to messages from that topic and silently ignores all others. Useful for supergroups with multiple Topics where each topic hosts a separate bot.

πŸ”Œ The "Backend Magic"

This bot is a Gateway. It orchestrates different AI services to provide a seamless experience.

1. Vision & Reasoning (OpenRouter) We use OpenRouter to access top-tier models like Gemini 2.0 Flash or GPT-4o.

  • Task: Analyze image pixels, estimate density/volume, calculate macros, and translate text.
  • Config: Change MODEL_NAME to swap models without redeploying code.

2. Ears (Whisper) We use a dedicated Whisper service for privacy and speed.

  • Task: Transcribe voice notes into text before sending them to the LLM.
  • Setup: Run a local docker container (e.g., onerahmet/openai-whisper-asr-webservice).

πŸ—οΈ Architecture Flow

  1. User sends a Photo, Voice, or Text πŸ“€
  2. Bot receives Webhook ⚑
  3. If Voice: Bot sends audio to WHISPER_API_URL -> gets text πŸ“
  4. If Photo: Bot encodes image to Base64 πŸ–ΌοΈ
  5. Bot sends payload (Image + Text + Date) to OPENROUTER_API_KEY 🧠
  6. AI analyzes calories, healthiness, and detects language πŸ‡ΊπŸ‡¦/πŸ‡ΊπŸ‡Έ
  7. Bot formats the JSON response and replies to user πŸ’¬

🀝 Contributing

Got a cool idea? Maybe adding a database for history tracking or user profiles? Fork the repo, make your changes, and open a Pull Request.

πŸ“„ License

This project is open-source and available under the MIT License.


Built with ❀️ for a healthier life.

About

Your smart AI Nutritionist. πŸ₯— Track calories via Photo πŸ“Έ, Voice 🎀, or Text πŸ’¬. Supports English πŸ‡¬πŸ‡§ & Ukrainian πŸ‡ΊπŸ‡¦

Topics

Resources

License

Stars

Watchers

Forks

Contributors