This guide explains how to configure your Jarvis AI Assistant using environment variables for secure credential management.
A comprehensive template containing all possible environment variables with explanations and default values.
A robust configuration management system that:
- Loads environment variables from
.envfile - Provides type-safe access to configuration values
- Includes logging setup
- Offers backward compatibility
An interactive setup script that guides you through configuring your environment.
python setup_env.pyThis will guide you through configuring all necessary settings.
- Copy
env_template.txtto.env - Edit
.envwith your actual credentials - Replace placeholder values with real API keys
- USER_NAME: Your name (default: "Varnit Kumar")
- USER_EMAIL: Your email address
- GOOGLE_SPEECH_API_KEY: For improved speech recognition
- PORCUPINE_ACCESS_KEY: For hotword detection
- HUGCHAT_COOKIE_PATH: For AI chatbot functionality
- OPENWEATHERMAP_API_KEY: For weather forecast features
GOOGLE_SPEECH_API_KEY=your_api_key_here
GOOGLE_SPEECH_LANGUAGE=en-US
SPEECH_RECOGNITION_TIMEOUT=10
SPEECH_RECOGNITION_PHRASE_TIMEOUT=8
SPEECH_RECOGNITION_PAUSE_THRESHOLD=1TTS_VOICE_ID=2
TTS_RATE=174
TTS_VOLUME=1.0
TTS_ENGINE=sapi5FACE_CASCADE_PATH=backend/auth/haarcascade_frontalface_default.xml
FACE_TRAINER_PATH=backend/auth/trainer/trainer.yml
FACE_SAMPLES_PATH=backend/auth/samples
FACE_RECOGNITION_CONFIDENCE=100
FACE_RECOGNITION_NAMES=Unknown,Unknown,Varnit KumarPORCUPINE_ACCESS_KEY=your_porcupine_key_here
PORCUPINE_KEYWORDS=jarvis,alexa
PORCUPINE_SENSITIVITY=0.5HUGCHAT_COOKIE_PATH=backend/cookie.json
HUGCHAT_MODEL_NAME=huggingface/CodeLlama-7b-Instruct-hfWHATSAPP_DEFAULT_COUNTRY_CODE=+91
WHATSAPP_MESSAGE_DELAY=5OPENWEATHERMAP_API_KEY=your_openweathermap_key_hereGet your free API key at: https://openweathermap.org/api
WEB_SERVER_HOST=localhost
WEB_SERVER_PORT=8000
WEB_SERVER_MODE=None
WEB_SERVER_BLOCK=truefrom backend.config_manager import config
# Get string values
assistant_name = config.assistant_name
user_name = config.user_name
# Get boolean values
debug_mode = config.debug_mode
face_recognition_enabled = config.face_recognition_enabled
# Get integer values
camera_width = config.camera_width
speech_timeout = config.speech_timeout
# Get list values
face_names = config.face_recognition_names
hotwords = config.porcupine_keywordsfrom backend.config import ASSISTANT_NAME, USER_NAME, DEBUG_MODE
# These now use the configuration manager internally
print(f"Assistant: {ASSISTANT_NAME}")
print(f"User: {USER_NAME}")
print(f"Debug: {DEBUG_MODE}")Ensure .env is in your .gitignore:
.env
*.env
.env.local
.env.production- Generate unique API keys for each service
- Rotate keys regularly
- Use environment-specific keys (dev/prod)
- Only grant necessary permissions
- Use read-only keys where possible
- Monitor API usage
- Store production keys in secure vaults
- Use different keys for different environments
- Never hardcode credentials in source code
Configuration not loading:
- Ensure
.envfile exists in project root - Check file permissions
- Verify syntax (no spaces around
=)
API keys not working:
- Verify key format and validity
- Check API quotas and limits
- Ensure proper permissions
Face recognition failing:
- Verify file paths in configuration
- Check camera permissions
- Ensure training data exists
Enable debug mode for detailed logging:
DEBUG_MODE=true
LOG_LEVEL=DEBUG
VERBOSE_LOGGING=true| Variable | Type | Default | Description |
|---|---|---|---|
ASSISTANT_NAME |
string | jarvis | Name of the assistant |
USER_NAME |
string | Varnit Kumar | Your name |
USER_EMAIL |
string | varnitkumar@example.com | Your email |
GOOGLE_SPEECH_API_KEY |
string | "" | Google Speech API key |
PORCUPINE_ACCESS_KEY |
string | "" | Porcupine hotword detection key |
OPENWEATHERMAP_API_KEY |
string | "" | OpenWeatherMap API key |
FACE_RECOGNITION_NAMES |
list | Unknown,Unknown,Varnit Kumar | Recognized face names |
WHATSAPP_COUNTRY_CODE |
string | +91 | Default country code |
WEB_SERVER_PORT |
int | 8000 | Web server port |
DEBUG_MODE |
bool | false | Enable debug mode |
If you have existing hardcoded values, follow these steps:
- Identify hardcoded values in your code
- Add corresponding environment variables to
.env - Update code to use configuration manager
- Test thoroughly to ensure functionality
Here's a complete example .env file:
# Application Settings
ASSISTANT_NAME=jarvis
USER_NAME=Varnit Kumar
USER_EMAIL=varnitkumar@example.com
# Voice Recognition
GOOGLE_SPEECH_API_KEY=your_google_api_key_here
GOOGLE_SPEECH_LANGUAGE=en-US
# Face Recognition
FACE_RECOGNITION_NAMES=Unknown,Unknown,Varnit Kumar
# Hotword Detection
PORCUPINE_ACCESS_KEY=your_porcupine_key_here
PORCUPINE_KEYWORDS=jarvis,alexa
# WhatsApp
WHATSAPP_DEFAULT_COUNTRY_CODE=+91
# Weather API
OPENWEATHERMAP_API_KEY=your_openweathermap_key_here
# Web Server
WEB_SERVER_HOST=localhost
WEB_SERVER_PORT=8000
# Feature Flags
FACE_RECOGNITION_ENABLED=true
HOTWORD_DETECTION_ENABLED=true
VOICE_COMMANDS_ENABLED=true
WHATSAPP_INTEGRATION_ENABLED=true
AI_CHATBOT_ENABLED=true- Run setup script:
python setup_env.py - Install dependencies:
pip install -r requirements.txt - Train face recognition:
cd backend/auth && python trainer.py - Test configuration:
python -c "from backend.config_manager import config; print('Config loaded successfully!')" - Run Jarvis:
python run.py
If you encounter issues with configuration:
- Check the logs in
logs/jarvis.log - Enable debug mode for detailed information
- Verify all file paths and permissions
- Ensure all required dependencies are installed
Created by Varnit Kumar - Your AI Assistant Configuration Expert! 🤖