You are on page 1of 25

FACE EMOTION BASED MUSIC PLAYER

A Project Report

SUBMITTED BY
SHUBHAM BHARTI (19011004084)

In Partial fulfilment for the award of the degree


Of

BACHELOR OF TECHNOLOGY AND ENGINEERING


IN

COMPUTER SCIENCE AND ENGINEERING


At

Aravali College of Engineering and Management


Jasana, Tigaon Rd, Neharpar Faridabad, Haryana, 121002
(AFFILATED TO YMCA UNIVERSITY OF SCIENCE AND TECHNOLOGY,
FARIDABAD(INDIA)
August-2022
DECLARATION

I hereby declare that the project work entitled “Face Emotion


Based Music Player” submitted to YMCA, Faridabad
(Haryana), is a record of an original work done by me under
the guidance of Ms. Shivani Pahuja Ma’am in Computer
Science and Engineering, ARAVALI COLLEGE OF
ENGINEERING AND MANAGEMENT, Faridabad.

This project is submitted in the partial fulfilment of the


requirements for the award of the degree of Bachelor of
Technology in Computer Science and Engineering.

Shubham Bharti Date: Aug 2022


Acknowledgment

Presentation inspiration and motivation have always played a key role in


the success of any venture.
We express our sincere thanks to Respected Dean sir, Aravali College of
Engineering & Management.
We pay our deep sense of gratitude to Prof. Sakshi Sachdeva Ma’am (HOD)
of CSE department, Aravali College of Engineering & Management,
Faridabad to encourage me to highest peak and to provide me the
opportunity to prepare the project. We are immensely obliged to my
friends for their elevating inspiration, encouraging guidance and kind
supervision in the completion of my project. We feel to acknowledge my
indebtedness and deep sense of gratitude to my guide and subject teacher
Ms.Shivani Pahuja Ma’am whose valuable guidance and kind supervision
given to me throughout the course which shaped the present project as it is
shown.
Last but not the least, Our Parents are also an important inspiration for
me. So, with due regards, we express my gratitude to them.

Shubham Bharti
CERTIFICATE

This is to certify that the project titled is “FACE EMOTION BASED


MUSIC PLAYER” is the bona fide work carried out by Shubham
Bharti, student of B Tech (CSE) of Aravali College of Engineering
and Management in Faridabad. Affiliated to YMCA University of
Science and Technology, Faridabad during the academic year
2021-22, in partial fulfilment of the requirements for the award of
the degree of Bachelor of Technology (Computer Science and
Engineering) and that the project has not formed the basis for the
award previously of any other degree, diploma, fellowship or any
other similar title.

Ms. Shivani Pahuja


Project Guide(Internal)
Signature
Date:

COUNTER SIGNED BY
Name: Signature
Date:
Index

Sr Contents Pag
. e
N No.
o
1. Declaration 2
2. Acknowledgement 3
3. Certificate 4
4. The introduction of the project 6
5. Scope of the Project 7
6. Flowcharts 8
7. Software Requirements 9
8. Hardware Requirements 10
9. Merits of the system proposed 11
10. Application of the system proposed 12

11. Specifying the contribution that the 13


project would make
12. Source Code 14-21
13. Output Screens 22-24
14. References 25
15. Conclusion 26
The Introduction of the project
Music is an important medium of life. Everyone likes to listen
music but what if we made more easier for user to listen
music by differentiating their mood? Now a days we have
grown up with advanced technology. Many mobile
applications have come up with many functions like emotion
capturing with artificial intelligence, gesture, sleeper time,
lyrics, shuffle play and many more. This application is
randomly similar that off but here we came up with new
function called Emotion Based Music Player with many
different Moods. Here user can select music list depending
on their current emotion or we can also call as mood so after
clicking to different types of mood a list of songs would be
displayed. And user can also search their favourite songs by
searching in-search tab. User can also create their playlist.
This application is made for online as well as offline too. User
can easily handle this application because many of us have
been using different kind of music players day-by-day.
Scope of the Project
Project Emotion Based Music Player is a novel approach
which helps user to play the songs according to their emotion
/ mood. In android we can apply many features. This
application is made for android users only from seventh
version which is (Nought) and further more. Firstly, user have
to sign up or login to access the application and then can
according search songs or by just clicking on moods user can
also access songs play list. user can also access this
application on desktop too. To access in desktop user, need
windows7 or further version. User can also upload his / her
playlist from device. Also, can download songs and also can
share from our application. In this application dark as well as
light theme are provided for user eye comfort. Users can
boost their sound in equalizer. Our application does not
contain any add because we have observed in many famous
applications they put add in middle and we get disturbed so
just to make user happy we haven’t collaborated with any
type of article add. And we believe in equality so we haven’t
added any premium package this application is same for all
user.
Data Flow Chart
Software Requirements
Requirement deal with define software resource
requirements and pre-requisites. That need to be installed on
a computer to Provide optimal functioning of an application.
 Windows/Linux/Mac OS any version, hence it can run
on any platform.
 Python 3.10.5
 HTML5
 CSS
 PyCharm
 Libraries Requirements
 OpenCV
OpenCV-Python is a library of Python bindings designed
to solve computer vision problems.
 Keras
Keras is an open-source software library that provides a
Python interface for artificial neural networks.
 NumPy 
NumPy is a Python library used for working with arrays.
It also has functions for working in domain of linear
algebra, Fourier transform, and matrices.
HARDWARE REQUIRMENT

In terms of hardware requirements there is not much


required at all but still below requirements are must :

 Working PC or Laptop
• Processor: - Ryzen 5 3450U.
• RAM: - 8 GB RAM.
• Space Required: - 500MB.
 Webcam with drivers installed
 Lan connection/ Internet service
 Flashlight/ LED if using this at night.
Merits of the system proposed

 The system is easy to use and is fully authorized.


 It can be used to listen music in every type of mood.
 It is not an electronic based system so one can
easily make use of laptops to use this system.
 It is free of cost.
 It also saves the time to find different types of
music.
 It maximizes accuracy and reduces storage space usage.
 More feature such as
o Find every language of songs
o Listen your favourite singer
o much more...
Application of the system
proposed

 Plays songs according to user mood and emotions.


 Act as plugins for website.
 Recommended for YouTube.
Specifying the contribution
that the project would
make

 The system can be used for Listen your favourite


music depend on your mood.

 The software can used to listen your favourite

singers.

 The system can be used to listen in different Languages.


Source Code
The coding part in below with specific modules
discussed below.
 App.py
from flask import Flask, render_template, request
import numpy as np
import cv2
from keras.models import load_model
import webbrowser

app = Flask(__name__)

app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 1

info = {}

haarcascade = "haarcascade_frontalface_default.xml"
label_map = ['Anger', 'Neutral', 'Fear', 'Happy', 'Sad', 'Surprise']
print("+"*50, "loadin gmmodel")
model = load_model('model.h5')
cascade = cv2.CascadeClassifier(haarcascade)

@app.route('/')
def index():
return render_template('index.html')

@app.route('/choose_singer', methods = ["POST"])


def choose_singer():
info['language'] = request.form['language']
print(info)
return render_template('choose_singer.html', data =
info['language'])

@app.route('/emotion_detect', methods=["POST"])
def emotion_detect():
info['singer'] = request.form['singer']

found = False

cap = cv2.VideoCapture(0)
while not(found):
_, frm = cap.read()
gray = cv2.cvtColor(frm,cv2.COLOR_BGR2GRAY)

faces = cascade.detectMultiScale(gray, 1.4, 1)


for x,y,w,h in faces:
found = True
roi = gray[y:y+h, x:x+w]
cv2.imwrite("static/face.jpg", roi)

roi = cv2.resize(roi, (48,48))

roi = roi/255.0

roi = np.reshape(roi, (1,48,48,1))

prediction = model.predict(roi)

print(prediction)

prediction = np.argmax(prediction)
prediction = label_map[prediction]

cap.release()

link = f"https://www.youtube.com/results?
search_query={info['singer']}+{prediction}+{info['language']}+song"
webbrowser.open(link)

return render_template("emotion_detect.html", data=prediction,


link=link)

if __name__ == "__main__":
app.run(debug=True)

 Frontend
 Index.html
<!DOCTYPE html>
<html>
<head>
<title>music recommend</title>
<link rel="stylesheet" type="text/css" href="{{url_for('static',
filename='style.css')}}">
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/
bootstrap.min.css" rel="stylesheet" integrity="sha384-
eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous">
</head>
<body style="background-color: #edffec;">

<div class="title">
<h1 class="display-4">Select Language</h1>
</div>

<form action="{{url_for('choose_singer')}}" method="POST">


<label><input type="radio" name="language" value="punjabi"
checked="true"><div class="box">punjabi</div></label>
<label><input type="radio" name="language" value="english"><div
class="box">english</div></label>
<br>
<label><input type="radio" name="language" value="hindi"><div
class="box">hindi</div></label>
<label><input type="radio" name="language" value="western"><div
class="box">western</div></label>

<br>
<input type="submit" name="btn" value="next" class="btn btn-
outline-success btn-lg">

</form>

<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/boots
trap.bundle.min.js" integrity="sha384-
JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
crossorigin="anonymous"></script>

</body>
</html>

 Emotion_detect.html
<!DOCTYPE html>
<html>
<head>
<title>detecting emotion</title>
<link rel="stylesheet" type="text/css" href="{{url_for('static',
filename='style.css')}}">
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/
bootstrap.min.css" rel="stylesheet" integrity="sha384-
eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous">
</head>
<body style="background-color: #edffec;">

<div class="title">
<h1 class="display-4">you looks like {{data}}</h1>
<h1><a href="{{link}}" title="">go to here</a></h1>
</div>

<img src="{{url_for('static', filename='face.jpg')}}">

</body>
</html>

 choose_singer.html
<!DOCTYPE html>
<html>
<head>
<title>song recommend</title>
<link rel="stylesheet" type="text/css" href="{{url_for('static',
filename='style.css')}}">
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/
bootstrap.min.css" rel="stylesheet" integrity="sha384-
eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous">
</head>
<body style="background-color: #edffec;">

<form action="{{url_for('emotion_detect')}}" method="POST">


{%if data == "punjabi"%}

<div class="title">
<h1 class="display-4">Punjabi Singer</h1>

</div>
<label><input type="radio" name="singer" value="sidhu
moosewala" checked="true"><div class="box">Sidhu
Moosewala</div></label>
<label><input type="radio" name="singer" value="amrinder
gill"><div class="box">Amrinder Gill</div></label>
<br>
<label><input type="radio" name="singer" value="karan
aujla"><div class="box">Karan Aujla</div></label>
<label><input type="radio" name="singer" value="diljit"><div
class="box">Diljit</div></label>

{%elif data == "english"%}

<div class="title">
<h1 class="display-4">English singer</h1>
</div>
<label><input type="radio" name="singer" value="punjabi"
checked="true"><div class="box">abc</div></label>
<label><input type="radio" name="singer" value="english"><div
class="box">aaa</div></label>
<br>
<label><input type="radio" name="singer" value="hindi"><div
class="box">bvc</div></label>
<label><input type="radio" name="singer" value="bhojpuri"><div
class="box">cvb</div></label>

{%else%}
<div class="title">
<h1 class="display-4">Choose your own singer</h1>

</div>
<input type="text" name="singer">
{%endif%}

<br>
<input type="submit" name="btn" value="next" class="btn btn-
outline-success btn-lg">
</form>

</body>
</html>

 Style.css
body{
text-align: center;
}

h1{
font-family: sans-serif;
color: #289672;
}
.title{
margin-top: 20px;
}
input[type="radio"]{
display: none;
}
.box{
background-color: #ddffbc;
height: 330px;
width: 450px;
padding: 30px;
text-align:center;
font-size: 40px;
font-family: sans-serif;
line-height: 220px;
margin: 10px 10px;
border: 2px solid #52734d;
border-radius: 10%;

}
.box:hover{
background-color: #91c788;
transition-duration: 1s;
}

input[type=radio]:checked + .box{
background-color: #52734d;
color: white;
transition-duration: 1s;
}
.btn{
width: 300px;
height: 60px;
}

img{
margin-top: 50px;
height: 400px;
border : 2px solid green;
border-radius: 30px;
}
Output Screens

 Language Selection

 Favourite Singer Selection


 Face Detection
o Happy Face Detection

o Sad Face Detection


o Fear Face Detection

o Neutral Face Detection

And Many more emotions…..


 Youtube Screen
CONCLUSION

This Project has been developed to give us a great


advancement in the field of human behaviour. In this project
we have used more than 9 moods which can be ordinarily
found in humans. Emotion Based Music Player fulfil to sort
out music based on moods. Our main aim is to consume
user’s time and to satisfy them. We have designed this
platform in such a manner that it can run in Web browser.
References

 www.google.com
 www.pypi.org
 www.stackoverflow.com
 www.github.com
 www.youtube.com

You might also like