Skip to content
Jaishree-2006Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

πŸŒ™ SilenceAI

An emotional AI companion that knows when NOT to reply.

Instead of always giving advice or long answers, SilenceAI sometimes pauses, stays silent, or guides you to breathe when you're emotionally overwhelmed.

SilenceAI React Flask


🎯 What Problem Does It Solve?

Most AI tools:

  • Talk too much
  • Give advice when you don't want it
  • Increase mental noise

SilenceAI does the opposite.
It reduces overload by responding less, not more.


πŸ”„ How It Works

  1. You type how you're feeling
    Example: "I'm really stressed and exhausted."

  2. AI reads the emotional intensity
    It analyzes if you're calm, anxious, angry, or overwhelmed

  3. If emotions are high β†’ AI slows down

    • No instant reply
    • Shows a breathing circle or calming message
    • Sometimes shows nothing for a few seconds
  4. After the pause, it responds gently
    Short, supportive lines like: "I'm here. No need to rush."


🧩 What Makes It AI (Not Just a Timer)

  • βœ… Detects emotional weight in text
  • βœ… Decides whether to respond or stay silent
  • βœ… Adjusts response length, timing, and tone
  • βœ… Learns what you find calming over time

✨ Features

🎨 Beautiful UI

  • Glassmorphic design with smooth animations
  • Animated breathing circle for calming exercises
  • Gradient backgrounds and particle effects
  • Responsive and modern interface

🧠 Intelligent Backend

  • Emotion Detection: Analyzes text for emotional intensity and sentiment
  • Smart Response Types:
    • 🫁 Breathing: For very high stress (shows breathing circle)
    • 🀫 Silence: For intense negative emotions (pause with minimal/no response)
    • ⏸️ Pause: For medium intensity (delayed gentle response)
    • πŸ’¬ Normal: For low intensity (gentle supportive message)

🎭 Response Modes

  • Breathing Exercise: 8-second guided breathing with animated circle
  • Silence Period: 3-5 seconds of quiet presence
  • Delayed Response: 2-3 seconds pause before gentle reply
  • Gentle Messages: Short, supportive responses (never preachy)

πŸš€ Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • Python (v3.8 or higher)
  • OpenAI API Key (optional, falls back to templates without it)

Installation

1. Clone the Repository

cd silenceai

2. Set Up Backend

cd backend

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# Mac/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Create .env file
copy .env.example .env
# Edit .env and add your OpenAI API key (optional)

3. Set Up Frontend

cd frontend

# Install dependencies
npm install

🎬 Running the Application

Start Backend (Terminal 1)

cd backend
venv\Scripts\activate  # Windows
# source venv/bin/activate  # Mac/Linux
python app.py

Backend will run on http://localhost:5000

Start Frontend (Terminal 2)

cd frontend
npm run dev

Frontend will run on http://localhost:3000

Open Your Browser

Navigate to http://localhost:3000


πŸ“ Project Structure

silenceai/
β”œβ”€β”€ frontend/                 # React + Vite frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ WelcomeScreen.jsx       # Initial welcome animation
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatInterface.jsx       # Main chat UI
β”‚   β”‚   β”‚   β”œβ”€β”€ BreathingCircle.jsx     # Breathing exercise overlay
β”‚   β”‚   β”‚   β”œβ”€β”€ Message.jsx             # Chat message bubble
β”‚   β”‚   β”‚   β”œβ”€β”€ TypingIndicator.jsx     # Typing dots animation
β”‚   β”‚   β”‚   └── SilenceIndicator.jsx    # Silence period indicator
β”‚   β”‚   β”œβ”€β”€ App.jsx          # Main app component
β”‚   β”‚   β”œβ”€β”€ main.jsx         # React entry point
β”‚   β”‚   └── index.css        # Global styles
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”‚
β”œβ”€β”€ backend/                  # Flask backend
β”‚   β”œβ”€β”€ app.py               # Main Flask application
β”‚   β”œβ”€β”€ emotion_detector.py  # Emotional analysis engine
β”‚   β”œβ”€β”€ response_generator.py # Response logic and generation
β”‚   β”œβ”€β”€ requirements.txt     # Python dependencies
β”‚   └── .env.example         # Environment variables template
β”‚
└── README.md                # This file

🎨 Design Philosophy

Visual Design

  • Glassmorphism: Semi-transparent elements with blur effects
  • Gradient Backgrounds: Calming purple-blue gradients
  • Smooth Animations: Framer Motion for fluid transitions
  • Minimalist: Clean, uncluttered interface

Interaction Design

  • Breathing Circle: Pulsing animation synchronized with breathing rhythm
  • Delayed Responses: Intentional pauses to reduce urgency
  • Gentle Language: Short, supportive messages
  • Non-Intrusive: Never forces interaction

Emotional Intelligence

  • Context Aware: Understands emotional intensity from text
  • Adaptive Responses: Changes behavior based on user state
  • Validation Over Advice: Acknowledges feelings without fixing
  • Respectful Silence: Knows when not to respond

πŸ§ͺ How Emotion Detection Works

Intensity Calculation (0-1 scale)

  • Keywords: High intensity words (stressed, anxious, overwhelmed)
  • Punctuation: Exclamation marks indicate intensity
  • Capitalization: ALL CAPS words show emotion
  • Repetition: Repeated letters (sooo, nooo)

Emotion Types Detected

  • Stress: overwhelmed, exhausted, stressed
  • Anxiety: anxious, panic, scared, worried
  • Sadness: sad, depressed, lonely, crying
  • Anger: angry, hate, furious, mad
  • Positive: Happy, good, great, amazing
  • Neutral: Normal emotional state

Response Logic

Intensity > 0.7 β†’ Breathing Exercise (8s)
Intensity > 0.5 + Negative β†’ Silence (3-5s)
Intensity 0.3-0.6 β†’ Pause (2-3s)
Intensity < 0.3 β†’ Normal Response (immediate)

πŸ”§ Configuration

Backend (.env)

OPENAI_API_KEY=sk-...           # Optional: For AI-generated responses
FLASK_ENV=development           # development or production
PORT=5000                       # Backend port

Frontend (vite.config.js)

server: {
  port: 3000,                   // Frontend port
  proxy: {
    '/api': 'http://localhost:5000'  // Backend proxy
  }
}

🎯 Use Cases

  • Stress Management: Guides breathing during panic
  • Emotional Processing: Validates feelings without judgment
  • Mindful Reflection: Encourages pause and presence
  • Anxiety Relief: Reduces overwhelm through silence
  • Digital Detox: Less is more approach to AI interaction

πŸ† In One Sentence

SilenceAI is an emotional AI that supports users by choosing silence, pauses, or minimal guidance when talking would do more harm than good.


πŸ› οΈ Technology Stack

Frontend

  • React 18.2 - UI framework
  • Vite - Build tool and dev server
  • Framer Motion - Animation library
  • Axios - HTTP client

Backend

  • Flask - Python web framework
  • TextBlob - Sentiment analysis
  • OpenAI API - GPT-3.5 for contextual responses (optional)
  • python-dotenv - Environment management

πŸ“ API Endpoints

POST /api/chat

Send a message and receive an intelligent response

Request:

{
  "message": "I'm feeling really stressed",
  "conversation_history": []
}

Response:

{
  "response_type": "breathing",
  "message": null,
  "pause_duration": 8000,
  "breathing_message": "Let's take a moment together."
}

Response Types:

  • breathing - Shows breathing circle
  • silence - Shows silence indicator
  • pause - Delayed response
  • normal - Immediate gentle response

GET /api/health

Check backend health status


🎨 Customization

Changing Colors

Edit gradients in frontend/src/index.css:

background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

Adjusting Timing

Edit durations in frontend/src/App.jsx:

setTimeout(() => {
  setShowBreathing(false);
}, 8000);  // Breathing duration

Modifying Responses

Edit templates in backend/response_generator.py:

self.gentle_responses = {
    'stress': ["I'm here.", "Take your time."],
    # Add your custom responses
}

🀝 Contributing

Contributions are welcome! This is a hackathon project focused on mindful AI interaction.

Ideas for Enhancement

  • Voice input/output
  • User preference learning
  • Multiple breathing patterns
  • Journal integration
  • Mobile app version
  • Offline mode
  • Custom themes

πŸ“„ License

This project is created for educational and hackathon purposes.


πŸ™ Acknowledgments

Built with the philosophy that sometimes the best response is silence.

Inspired by mindfulness practices and the understanding that AI doesn't always need to have the last word.


πŸ“§ Contact

For questions or feedback about SilenceAI, feel free to reach out!


Remember: You don't always need an answer. Sometimes you just need to be heard. πŸŒ™

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages