Emotion Based Music Player: Graduate Project Report
Emotion Based Music Player: Graduate Project Report
Emotion Based Music Player: Graduate Project Report
by
Committee Members
Recent studies confirm that humans respond and react to music and that
music has a high impact on person’s brain activity. The average American listens up to
four hours of music every day [2]. People tend to listen to music based on there mood
and interests. This project focuses on creating an application to suggest songs for
user based on their mood by capturing facial expressions. Facial expression is a form
of nonverbal communication. Computer vision is an interdisciplinary field that helps
convey a high-level understanding of digital images or videos to computers. In this
system, computer vision [18] components are used to determine the user’s emotion
through facial expressions. Once the emotion is recognized, the system suggests a
play-list for that emotion, saving a lot of time for a user over selecting and playing
songs manually. Emotion-Based Music Player also keeps track of user’s details like
number of plays for each song, sorts songs based on category and interest level, and
reorganizes the play-list every time. The system also notifies user about the songs
, recommendations.
ii
TABLE OF CONTENTS
Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
List of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
2 Project Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.5 Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4 IMPLEMENTATION . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1 MongoDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2 Express.js . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.3 Angular.js . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.4 Node.js . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.5 Cordova . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
iii
4.7 Firebase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.8.4 EMO-Phase . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.10 Recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5.2 Test Case for Capture and Display Play-list based on Emotion . 38
iv
5.4.3 EMO-algorithm Test Case Scenario 3 . . . . . . . . . . . 43
v
LIST OF FIGURES
4.5 Signup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.6 Login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
vi
5.21 Wrong Email Format . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
vii
1. BACKGROUND AND RATIONALE
are many traditional music players that require songs to be manually selected and
organized. User, have to create and update play-list for each mood, which is time
consuming. Some of the music players have advanced features like providing lyrics and
recommending similar songs based on the singer or genre . Although some of these
features are enjoyable for user, there is room to improve in the field of automation
when it comes to music players. Selecting songs automatically and organizing these
based on the user’s mood gives user’s a better experience. This can be accomplished
through the system reacting to the user’s emotion, saving time that would have been
device’s camera, we can capture the user’s facial expression. There are many emotion
recognition systems which take captured image as input and determine the emotion.
For this application, we are using Affectiva SDK [7] for recognition of emotion. The
system includes a novel algorithm [EMO-algorithm] that organizes songs based on the
user’s emotions and preferences. This algorithm suggests user’s songs to play based
on their emotion.
preferences and recommendations, and these are not customizable, like AllMusic [3].
1
Other applications suggests predefined (not user-specific)song play-lists. Application
like moodfuse [12] include features like manual selection of songs, partly shuffle, play-
list. Some popular music applications like Saavn [16], Spotify provide users defined
play-lists that needs to be created and updated manually. All of these applications
focus on general categorization rather than specificity to every user. A dedicated ap-
plication that focuses more on user preferences, priorities and the creation of dynamic
play-list is required to optimize the user experience. It should contain user specific
emotion, but these techniques have high computational requirement. The alternative
is to use a cloud-based web service [7] that process computation in the cloud. The
current system uses, Affectiva SDK for emotion recognition, a system that has al-
ready analyzed emotions from over five million faces. This SDK helps the application
capture and determine emotion from a picture. Later, this emotion can be used to
organization of user’s play-list.
2
2. PROJECT OVERVIEW
Music listeners have tough time creating and segregating the play-list manually
when they have hundreds of songs. It is also difficult to keep track of all the songs:
sometimes songs that are added and never used, wasting a lot of device memory and
forcing the user to find and delete songs manually. User’s have to manually select
songs every time based on interest and mood. User’s also have difficulty to re-organize
and playing music when play-style varies. Currently in existing application, music
is organized using play-list, and play-list songs cannot be modified or altered in one
click. User’s have to manually change or update each song in their play-list every
time. The sequence of songs in a play-list might not be the same every time, and
songs that a user wants to listen frequently might not be given priority or might be
left out from the list. Currently, there are no applications that allows users to play
2.2 Motivation
As a music lover, I’ve always felt that music players should do far more things
than just playing songs and allowing users to create play-lists. A music player should
be intelligent and act according to user’s preferences. A music player should help
users organize and play the songs automatically without putting much effort into
their moods. The player should also give recommendation for users to change songs
on-the-go. It calculates song-weight based on EMO-algorithm (discussed in chapter
3
4) to help users have more customized and organized play-lists.
The Emotion Based Music player requires the user to have a profile to access
the application. The user needs to grant permissions for the application to access
the device’s camera and media. The application allows users to upload songs and
give feedback on the song. Emotion-Based Music Player saves the user profile on the
device and keeps the profile logged-in until user logs out of the device manually. As
soon as the user opens the application, the device’s camera opens and begin capturing
images. The system will determine emotions and create play-lists for the user based
on emotion captured. The application also allows user’s to easily customize the play-
lists. It recommends songs for the user that may fit their current emotion, helping
the user automate the initial song selection. The recommendations are based on the
previous information about the user’s preferences and usage.
Emotion Based Music player is a useful application for music listeners with a
2. Adding songs
3. Removing songs
4. Updating songs
4
5. Personalized play-list
6. Recommendations
2.5 Functionality
The main functionality of this application is to give users more features to auto-
mate the selection and organization of the songs based on user preferences. Initially,
the user uploads each song and gives details about the song, like category and interest
level. Songs are listed and categorized based on user’s interest. The Emotion-Based
Music Player givens user’s feedback about their usage. It also notifies user’s of songs
1. Hardware requirements
• Processor: 2 GHz
• RAM : 1 GB
2. Browser
• Chrome 51 or higher
• Firefox 47 or higher
• Opera 37
• Edge 10586
5
3. Database
• Firebase
• NoSQL
Currently, there are many existing music player applications. Some of the inter-
esting applications among them are:
• Saavan and Spotify – These application [16] gives good user accessibility features
to play songs and recommends user with other songs of similar genre
• Moodfuse - In this application [12], user should manually enter mood and genre
• Steromood - User should select his mood manually by selecting the moods from
the list and the application [17] plays music from YouTube
• Musicovery - This application [3] has High quality songs and comprehensive
music recommendations. It also suggest predefined play-list for the user.
6
3. SYSTEM ARCHITECTURE AND DESIGN
The system architecture of Emotion-Based Music player is shown in Fig 3.1. The
application is built using the architectural pattern of Model-View-Controller [13]. It
is also widely used architecture. Here, the application is divided into three main
logical components: the model, the view and the controller.
• View: The top layer is where the end-user communicates with the application
through clicking buttons, typing details, accessing camera, selecting radio but-
ton, uploading songs, etc. This layer is responsible for displaying all data or a
7
portion of data to user based on the requirement of the application. This layer
also acts as a bridge between the user and application itself. Angular 4 [4] is
used in this application for displaying the output or response of the system to
the user.
• Controller: This middle layer of the application contains the business logic,
and the main functionality of the application. As soon as the user interacts
with the application, the response is processed in this layer. From log-in to
displaying play-list, all the functions that run in background belong to this
• Model: This layer is responsible for maintaining the user’s data. Emotion-Based
Music Player uses Google Firebase [8] for storing user data. Firebase is very
useful to maintain user’s profiles and preferences. The application also stores
some temporary data on the device.
thing written in JavaScript [9]. Both the server-side and client-side executions
are performed using JavaScript to increase the speed of the application.
8
3.1 System Overview
This section illustrates the design and functional phase of the application. Emotion-
Based Music Player is installed on a mobile device, where the user can access their
customized play-lists and play songs based on their emotions. Fig 3.2 depicts the
overview of the application
date. If the user already has an account, they can log-in to their account to
access customized play-lists as well as songs. Once user logs-in, their profile
is saved on the application, until they manually log-out. While the user adds
songs, their input(i.e category and interest level) is taken by the system.
9
2. Emotion Capture phase: As soon as the authentication phase is done, the ap-
plication will ask user’s permission to access media and photos and will access
camera to capture the user’s image.
3. Affdex API: After the image is captured, the application sends image captured
to Affdex SDK [7]. There, the captured image is processed and the image
4. Emo-phase: In this phase, the application receives the image information and
recognizes the emotion based on the defined threshold. This emotion is sent to
the database to fetch the emotion play-list.
5. Display phase: Here, the songs are organized based on EMO-algorithm and the
user can play any song from the list displayed. The user has the option to add,
remove, modify the songs and also can change category and interest level of a
song at anytime in the application. The application also has a recommendation
tab where the system notifies the user of songs that are rarely played.
10
4. IMPLEMENTATION
Player, with everything written in JavaScript, where M stands for MongoDB, E stands
for Express.js, A stands for Angular, N stands for Node.js
4.1 MongoDB
using regular expressions. It contains user defined JavaScript functions which can
return specific fields of documents. MongoDB also gives good results if configured to
return some random sample of results of any given size.
11
4.2 Express.js
side. Express helps in managing everything from routes to handling requests and
views.
4.3 Angular.js
exactly each component of the page should function as. This framework adapts and
extends traditional HTML to present dynamic content through two-way data binding
that allows for the automatic synchronization of model and view as shown in Fig 4.4.
12
4.4 Node.js
script on server-side to produce dynamic content before the web-page is sent to the
user’s web browser.
4.5 Cordova
they are neither native or web-based applications. So the same code can be used for
both mobile and web application.
4.7 Firebase
Firebase [8] is a mobile and web application development platform. It has many
features available for developers, based on developers needs they can mix and match
13
to fit their needs related to the database. Firebase is known for its real time database
The Emotion-Based Music Player needs a user account to store the user prefer-
ences. Once the user logs-in and the application loads the required components and
the detector, the user can click camera button to capture their image. Once the image
is captured, it is sent to the SDK, which returns the emotion to the application.
The system is currently designed to recognize four basic emotions: happiness, sad-
ness, anger and disgust. After the emotion is recognized, the system runs the Emo-
algorithm to categorize and display the play-list to the user. This algorithm considers
multiple criteria for segregating and displaying songs to the user, which will later be
discussed in detail. The user can change song details like category and interest level
at any time in the application. The system also notifies the user of songs that are
infrequently played so that they can change songs or delete the songs if it does not
fit in the category.
If the user is accessing the application for the first time, they need to register
for the application as shown in Fig 4.5. The user must give valid email address, name
and password. If the user forgets their password an email to reset the password is sent
to registered email address. All the information is validated and account creation is
finished. Users cannot create multiple accounts with the same email.
14
Fig. 4.5. Signup
Fig 4.6 depicts the user log-in screen. The user should provide a registered
email address and corresponding password to log-in to the application and the in-
formation will be saved on cloud. The application saves the user’s authentication
information as the default. The user can log-out of the application any time.
15
Fig. 4.6. Login
Once the user successfully logs-in to the application, the system loads the
SDK for capturing the user’s image. The user is redirected to an error page if they
As soon as user logs-in to the application, the system loads the required
components and loads the Affectiva SDK. If the user is logging in for the first time,
the user’s profile and preferences are created during this phase, as shown in Fig 4.7
16
Fig. 4.7. loading SDK
In this phase, the system creates space on the local device for loading the
SDK. This SDK is a detector used to capture the user’s image. An Internet connection
17
4.8.3 Emotion Capture Phase
Emotion Detector
Once the SDK is loaded, the starting detector screen appears as shown in
Fig 4.8 and opens device’s camera to capture the emotion. If the application is running
for the first time, the application asks permissions to access media and camera.
The captured image quality depends on the user’s device. Each device has
its own capturing techniques, and the Emotion-Based Music Player inherits all the
18
features of the device’s regular camera.
prompts the user to accept or retake the captured image. Then the captured image
is sent to the SDK to detect the image’s emotion.
Post Detection
and the user is alerted of the result, as shown in Fig 4.9. The application supports
four emotions: happiness, sadness, anger, disgust.
Various alert messages are displayed when an emotion is detected. These alerts
notify the user of the emotion recognized by the SDK or if no emotion is detected
among the four supported by the system. It also gives the user feedback by displaying
an error message when image capturing is not completed properly.
During this phase, before alerting to the user, the application runs EMO-algorithm
(discussed in next section) and fetches results for the user in application’s backend.
The EMO-algorithm uses user’s details and usage to generate a custom segregated
19
Fig. 4.9. Emotion Feedback to user
After user presses OK, the application redirects to music player screen for
the detected emotion.
4.8.4 EMO-Phase
This is most important phase of the application. In this phase, we use the
EMO-algorithm, which calculates the order in which songs should be organized or
segregated in the play-list. The user’s customized music list is created based on the
system’s knowledge of the user. The system provides users with more customized
20
play-lists based on their usage, play-styles, and preferences.
EMO-algorithm
Data: interest level and category while adding song, count of song, user
changing song category, skip the song
else
{ interest level(60%) + (song count -1)(40 %) ;
}
else
calculate the song based on interest level
end
else
calculate the song based on initial input ;
end
end
Algorithm 1: EMO-algorithm to calculate the weight of song
21
In this phase, the segregation of songs in a category is calculated. When the
user adds a song to the application, the song’s details are also taken by the application,
which comprises of song category and user interest level. Once user begins using the
application, the EMO-algorithm considers many factors for customizing the play-
list.Factors that are considered for calculating the weight of the song are:
The EMO-algorithm uses the following formula to calculate the song weight,
based mainly on song based on interest level and number of times each song is played:
Song Weight = (60%) number of times played + (40%) song interest level
This algorithm is designed to work even if the user skips the song. The system
assumes that user is not interested in the song and reduces the weight.
Using the Algorithm 1, the application categorizes songs of each emotion and
displays them to the user as shown in Fig 4.10
Each user has their own customized play-list. The user can add new songs to the
music player, and by using the EMO-algorithm, all the songs are reorganized at run
time. The song weights are calculated every time the user runs the application.
22
Fig. 4.10. Song-List for Happy emotion
Once the user’s emotion is determined, this whole process runs in the back-
ground and will fetch songs, organizes and re displays the play-list to the user. The
user can change the song category or interest level at anytime in the application and
the system keeps track of the data.
23
4.9 EMO-algorithm Scenarios
The following are the scenarios to depict the segregation of play-list using EMO-
algorithm
In Fig 4.11, the user played song1 more number of times than song4. Ac-
cording to the EMO-algorithm, once user starts listening to the songs, the algorithm
24
considers both song count and interest level for song weight.
Here, song1 with low interest level and played more times tops the list based
on the song weights, the weights of songs are as shown below :
In the following series of test scenarios from Fig 4.12 - Fig 4.14, the applica-
tion is tested using many songs to demonstrate how the application handles situations
of equal weights.
25
4.9.2 EMO-algorithm Scenario 2
26
Based on the EMO-algorithm, song1 is on top of list, since its interest level
In Fig 4.13, user played song4 one more time than in the previous scenario
[Fig 4.12], and the weight for the song4 has changed. In this instance, the algorithm
calculates based on weights and the weight of song4 has increased from 12.0 to 12.6,
The song weights are calculated as shown below.
27
Weight of song4 = 18 *(0.6) + 1.8 = 12.6
In Fig 4.14, the user has played song2 19 times and its weight is more than song4
and song1. Now song2 comes on top of the list, as shown as Fig 4.14
28
4.9.5 Adding Song
User’s will be provided the option to add songs in the applications. Songs
are added manually – users upload and provide details for each songs. These details
As soon as the user clicks on ”‘Add song”’, the media is accessed to check
the local devices files. The application searches for songs by checking the file exten-
sion(i.e .mp3), allowing user to add songs from various locations . Options include
29
adding from Google Drive, audio files, file manager, and downloads folder, as shown
in Fig 4.15. Fig 4.16 shows the process of choosing and adding songs.
30
The user needs to provide interest level and category for each song, as shown
in Fig 4.17
Currently, the application supports four emotions. Each song can be added under
one of these four categories.
The emotions are:
1. Happy
2. Sad
31
3. Anger
4. Disgust
These four categories of emotions, each has a defined play-list for each user. A
song can be placed in multiple categories based on user interest. For instance, there
might a song the user likes to hear when they are either angry or sad. In this scenario,
the user can add the song and set its interest level in both the angry category and
a song but not be crazy about it, and could set the song interest as either medium or
low interest level. The user can modify category and interest for a song at any point.
The user can set a song at three interest levels as shown in Fig 4.18, which have
pre-defined weights relative to each other to help the user in listing the songs in the
play-list.
32
Fig. 4.18. User’s input for Interest
1. High Interest
2. Medium Interest
3. Low Interest
These play a vital role in calculation of song weight. If the weight changes, the
organization of the songs also changes.
33
4.9.6 Saving Song
Once the user enters the song details, the application uploads the song to
cloud and saves the user’s preferences. Internet connectivity is required for this part.
The applications display the message ”‘loading songs..please wait”’at this time, as
34
4.10 Recommendations
The Emotional-Based Music Player gives the user song recommendations for each
emotion so the user is aware of songs that are never played or less played, as shown
in Fig 4.20. It gives the user option to edit the songs if they fit in other categories or
35
5. TESTING AND EVALUATION
To test the application, the following are the testing categories formulated.
The user must be able to create a profile, and if they already have a profile, they
If the user forgets his password, he must be able to reset password. The test for
36
this scenario is to check if email is in proper format and credentials are validated. If
user does not enter email properly, then the error as shown in Fig 5.21 is displayed.
If the user tries to log-in to application using wrong credentials, the error message
as shown in Fig 5.22 is displayed. There are similar test cases for the sign-up process
to check the redundancy of user accounts. User’s can have multiple accounts with
37
5.2 Test Case for Capture and Display Play-list based on
Emotion
Based on the emotion captured using the camera, the user is notified by the
The system recognizes and alerts the user’s emotion as ’Sad’ based on Af-
fectiva SDK as shown in Fig 5.23.
38
Based on the emotion captured the play-list that is associated with the
The system displays ’Sad Play-list’ as shown in Fig 5.24, since SDK rec-
ognizes Sad .
39
5.3 Test Case for Adding or Editing a Song
The user must provide the category and interest level of the song that is uploaded.
If the user does not provide this information, they will see the error shown in Fig 5.25.
All fields are mandatory while adding and editing a song. The weight is calculated
40
5.4 Test Case Scenarios for EMO-algorithm
The following are the test case scenarios that were tested to check EMO-algorithm.
In the above test scenario, songs were added by the user but never played.
In this situation, the songs are categorized based on the interest level of the user
according to the EMO-algorithm as shown in Fig 5.26. Songs that are of high interest
41
are at the top of the list and songs that are of low interest are at the bottom of list.
In Fig 5.27, songs are played less than five times (the threshold value).
Here, the application will segregate the songs based on only interest level and will
not consider the number of times the song has played. The song order obtained from
42
5.4.3 EMO-algorithm Test Case Scenario 3
In Fig 5.28, songs are played more than five times. According to the EMO-
algorithm, the application will categorize and segregate based on both interest level
and number of times song is played. The application will consider the value of
plays since the threshold value has been crossed. Song1(Low)(count-8) has overtaken
song2(Medium)(count-5) for second place.
43
6. CONCLUSION AND FUTURE WORK
The Emotion-Based Music Player is used to automate and give a better music
player experience for the end user. The application solves the basic needs of music
up storage space.
• Current application uses Affectiva SDK that has a lot of limitations, creating
custom emotion recognition system that can be merged into the current appli-
cation improves functionality and performance of the system.
gesting the user to travel to that location and play songs accordingly.
44
BIBLIOGRAPHY AND REFERENCES
45
[18] Abat, F., Maaoui, C., and A.Prusk. Human-computer interaction using
emotion recognition from facial expression. 2011 UKSim 5th European Sympo-
sium on Computer Modeling and Simulation (2011).
[19] Viola, P., and Jones, M. Rapid object detection using a boosted cascade of
simple features. Proceedings of the 2001 IEEE Computer Society Conference on,
46