An open API service indexing awesome lists of open source software.

https://github.com/karansingla-dev/emotion-music-player


https://github.com/karansingla-dev/emotion-music-player

deepface docker docker-compose fastapi nextjs pytorch spotify-web-api tailwindcss tensorflow

Last synced: 29 days ago
JSON representation

Awesome Lists containing this project

README

          


Emotion-Based Music Player

# 🎢 Emotion-Based Music Player

An **AI-powered music recommendation app** that detects your real-time **facial emotions** πŸŽ₯ and suggests personalized **Spotify tracks** 🎡 based on your **mood, language, and genre preferences**.

Built with **FastAPI + Deep Learning (FER/DeepFace) + Next.js + Tailwind + Spotify API + Docker** πŸš€

---

## ✨ Features

- βœ… Real-time **emotion detection** from webcam (happy, sad, angry, surprise, neutral, etc.)
- βœ… **Spotify integration** to fetch recommended tracks 🎧
- βœ… User can choose **preferred language** (English, Hindi, Punjabi, etc.)
- βœ… User can choose **preferred genre** (Pop, Rock, Classical, Lofi, etc.)
- βœ… Built-in **music player** (Play, Pause, Seek) using Spotify `preview_url`
- βœ… **Fallback to Spotify app** if no preview available
- βœ… Beautiful **UI with Tailwind + Framer Motion animations**
- βœ… **Dockerized backend** for smooth deployment

---

## πŸ–ΌοΈ Demo

![screenshot](assets/demo1.png)
![screenshot](assets/demo2.png)

---

## πŸ—οΈ Tech Stack

### 🎯 Frontend
- [Next.js 14](https://nextjs.org/) + [React](https://react.dev/)
- [Tailwind CSS](https://tailwindcss.com/) for styling
- [Framer Motion](https://www.framer.com/motion/) for animations

### ⚑ Backend
- [FastAPI](https://fastapi.tiangolo.com/)
- [FER](https://github.com/justinshenk/fer) / [DeepFace](https://github.com/serengil/deepface) for emotion recognition
- [TensorFlow](https://www.tensorflow.org/) & [PyTorch](https://pytorch.org/)
- [Spotify Web API](https://developer.spotify.com/documentation/web-api/)

### 🐳 Deployment
- Docker + Docker Compose

---

## πŸš€ Getting Started

### 1️⃣ Clone the Repo
```bash
git clone https://github.com/your-username/emotion-music-player.git
cd emotion-music-player
```

---

### 2️⃣ Backend Setup (FastAPI + Docker)
```bash
cd backend
cp .env.example .env # add your SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET
docker compose up --build
```

Backend will start on:
πŸ‘‰ [http://localhost:8000/docs](http://localhost:8000/docs)

---

### 3️⃣ Frontend Setup (Next.js)
```bash
cd frontend
npm install
npm run dev
```

Frontend will run on:
πŸ‘‰ [http://localhost:3000](http://localhost:3000)

---

### 4️⃣ Spotify API Setup
1. Go to [Spotify Developer Dashboard](https://developer.spotify.com/dashboard/)
2. Create a new app β†’ get `CLIENT_ID` and `CLIENT_SECRET`
3. Add them in `backend/.env`:

```env
SPOTIFY_CLIENT_ID=your_id_here
SPOTIFY_CLIENT_SECRET=your_secret_here
```

---

## πŸŽ₯ How It Works

1. User opens the app β†’ grants camera permission
2. Camera captures frames every few seconds
3. Backend analyzes face β†’ detects emotion
4. Based on emotion + selected **language/genre**, Spotify API is queried
5. App displays recommended songs with a built-in music player

---

## πŸ“‚ Project Structure

```
emotion-music-player/
β”œβ”€β”€ backend/ # FastAPI + Emotion Detection
β”‚ β”œβ”€β”€ app/
β”‚ β”‚ β”œβ”€β”€ main.py # FastAPI routes
β”‚ β”‚ β”œβ”€β”€ emotion.py # Emotion detection logic
β”‚ β”œβ”€β”€ Dockerfile
β”‚ β”œβ”€β”€ requirements.txt
β”‚
β”œβ”€β”€ frontend/ # Next.js + Tailwind
β”‚ β”œβ”€β”€ src/app/
β”‚ β”‚ β”œβ”€β”€ player/page.tsx # Main player UI
β”‚ β”‚ β”œβ”€β”€ components/ # AudioPlayer, CameraCapture etc.
β”‚ β”œβ”€β”€ package.json
β”‚ └── tailwind.config.js
β”‚
|── docker-compose.yml
β”œβ”€β”€ assets/ # Screenshots, banner, GIFs
β”‚ └── banner.png
β”‚
└── README.md
```

---

## πŸ› οΈ Future Improvements

- 🎀 Voice commands (e.g., β€œplay happy songs”)
- πŸ“± Mobile app version with React Native / Flutter
- 🀝 Multi-user support with accounts
- 🎨 More advanced UI like Spotify clone

---

## πŸ‘¨β€πŸ’» Contributors

- **Your Name** – [@karansingla007](https://github.com/karansingla007)

---

## ⭐ Support

If you like this project, don’t forget to **star ⭐ the repo**.
Pull requests are welcome πŸš€

---