Journal of Cognitive Human-Computer Interaction

Personalized Music Playlists via Deep Learning Emotion Detection

M. Spoorthi, Harshitha H. M., Pooja R., Anusha M. K., Preethi R.
Volume 8, Issue 2, pp. 15–19 (2024)
DOI: https://doi.org/10.54216/JCHCI.080204
Online: https://americaspg.com/journal/25/article/2904

Abstract

Music holds significant sway in enriching the lives of individuals, serving as a vital source of entertainment for enthusiasts and listeners alike. Moreover, it transcends mere amusement, often adopting a therapeutic role in people’s lives. In the ever-evolving landscape of music and technology, this project emerges as a groundbreaking endeavor, driven by the profound impact music holds on individuals’ lives. Leveraging technological advancements in music players, such as playback control and genre classification, our focus is on revolutionizing playlist creation. Instead of the laborious manual curation of playlists, we introduce automation based on users’ emotional states, identified through real-time facial expression analysis via a camera. The human face, a rich source of mood indicators, becomes the key input for our system. By directly extracting emotional cues from facial expressions, the project aims to swiftly deduce the user’s emotional state, crafting a tailored playlist without the need for time-consuming manual efforts. Implemented through deep learning using VGG16 model, the system ensures intricate emotion recognition from image input. Python, OpenCV, and Keras facilitate seamless video processing and deep learning functionalities, complemented by a music player library for smooth playback control. This amalgamation of computer vision and deep learning delivers an interactive music player that dynamically selects tracks aligned with users’ real-time emotional expressions, offering a personalized and immersive musical experience.

Keywords: Visual Geometry Group (VGG16); Computer Vision; Emotion Detection; Deep Learning

1. INTRODUCTION

analyzing facial cues and expressions, FER systems can infer users’ emotional states and tailor experiences accordingly.

The field of emotion-based music recommendation has witnessed significant advancements, driven by growing interest in leveraging human emotions to enhance personalized experiences. Understanding and interpreting human emotions, particularly through facial expressions, plays a pivotal role in designing interactive systems such as emotion-based music players. Emotion detection systems offer applications across education, healthcare, and entertainment. In recent years, facial expression recognition (FER) has emerged as a prominent technique for detecting human emotions. By

This paper explores the development of an emotion-based music player system that integrates FER algorithms, specifically convolutional neural networks (CNNs) and Local Binary Patterns Histograms (LBPH), to accurately identify users’ emotions from facial images. Unlike conventional approaches that often rely solely on pre-trained models or singular techniques, the system combines the strengths of CNNs and LBPH to achieve robust emotion detection. The work also leverages the efficiency and effectiveness of the VGG16 architecture for feature extraction and classification. By fine-tuning VGG16 on a custom dataset, the system improves accuracy in recognizing emotional states and recommends music tracks that resonate with users’ detected emotions.

Figure 1. Seven basic human emotions.
Figure 1. Seven basic human emotions.

1.1 Motivation

The motivation behind crafting personalized music playlists through emotion detection using deep learning, specifically leveraging VGG16, is rooted in the effort to revolutionize the music listening experience. The project seeks to integrate deep learning models capable of deciphering real-time emotions from facial expressions. The underlying drive is to create a sophisticated system that detects the user’s face and interprets emotional state with nuance. Combining the technical strength of VGG16 in image classification with the emotional resonance of personalized playlists enables a dynamic and immersive journey through music, driven by the fusion of artificial intelligence and emotion-aware entertainment.

1.2 Objective

The primary objectives of this research are:

1. To implement robust emotion detection algorithms within the music player to accurately analyze users’ facial expressions and understand emotional states.

2. To develop a user-friendly interface that integrates facial emotion detection, automatically generates personalized playlists tailored to mood, and allows users to customize the sensitivity of emotion detection features.

3. To refine and optimize the emotion detection model through machine learning, ensuring adaptability to diverse facial expressions and dynamically adjusting song recommendations based on real-time emotional changes during playback.

Chaohui Lv et al. [1] reviewed methods and algorithms for image signal processing, biomedical engineering, and informatics, including segmentation, feature extraction, and classification. Mehmet Bilal Er and Ibrahim Berkan Aydilek [2] developed music emotion recognition using chroma spectrograms and deep visual features. Harsha Vijay Bodhe [3] explored music recommendation based on facial expression recognition and deep learning, mapping detected expressions to corresponding music tracks.

Atabansi et al. [4] investigated transfer learning with VGG16 for near-infrared facial expression recognition and reported strong accuracy on the Oulu-CASIA NIR dataset. Indumathi et al. [5] proposed a real-time emotion-based music player using CNN architectures and transfer learning models. Chankuptarat et al. [6] presented an emotion-based music player that suggests songs using heart-rate or facial-image analysis.

Other works have examined affective gaming, CNN-based real-time emotion detection, and machine-learning music players that select songs according to detected emotions [7, 4, 8]. Mood-based and smart-home systems have also used facial expression detection and playlist selection to synchronize music with user states [9, 10, 11]. Several related systems employ Fisher Face, Haar cascade, EMO algorithms, APIs, and facial-recognition pipelines to generate personalized playlists based on moods [12, 13, 14, 15, 16, 17, 18].

3. PROPOSED METHODOLOGY

The proposed system integrates live image acquisition, preprocessing, feature extraction, fine-tuning, emotion classification, and music recommendation. A camera captures the user’s facial image, preprocessing removes irrelevant information, and VGG16 extracts discriminative facial features. A classifier predicts the emotion class, and a recommendation engine retrieves songs that match the detected mood.

3.1 Image Acquisition

The system first acquires facial images from a webcam. Face detection algorithms such as Haar cascades and LBPH localize the face in real time. Background subtraction separates the user’s face from the surrounding scene by analyzing pixelintensity differences between frames. Image enhancement, including brightness, contrast, sharpness adjustment, noise reduction, and color correction, improves visual clarity. Resolution and frame-rate control balance detailed capture with computational efficiency.

Figure 2. Proposed methodology.
Figure 2. Proposed methodology.

3.2 Preprocessing

Preprocessing prepares the acquired images for analysis. Background subtraction removes irrelevant visual content and isolates the region of interest. Image cropping retains the facial region only, reducing computational complexity.

Image resizing standardizes the cropped face to 224 × 224 pixels, matching the input requirements of VGG16. Normalization adjusts pixel values to a common scale, mitigating variations in lighting and color intensity. Data augmentation applies transformations such as rotation, flipping, and scaling, increasing training diversity. Quality-control steps remove low-quality or blurry images to improve reliability.

3.3 Feature Extraction

Feature extraction transforms preprocessed images into informative representations of facial expressions. CNNs learn hierarchical representations directly from pixels through convolutional, pooling, and fully connected layers. VGG16, pre-trained on ImageNet, is used as a feature extractor and fine-tuned for emotion detection. Feature maps generated by convolutional layers capture edges, textures, and higher-level facial structures such as eyes, nose, and mouth. Pooling layers reduce spatial dimensions while retaining key information, and ReLU activation introduces non-linearity for learning complex expression patterns.

3.4 Fine-Tuning and Classification

Fine-tuning adjusts the parameters of the pre-trained VGG16 network to adapt it to facial expression recognition. The weights of selected layers are updated during training so that the model learns subtle patterns essential for emotion classification. Dense layers are added on top of the convolutional base to map extracted features to emotion classes. Dropout layers reduce overfitting, and a softmax classifier computes the probability of each class. The predicted emotion is selected as the class with the highest probability:

P(y = i | x) = ezi

i P(y = i | x), (1)

j=1 ez j , ˆy = argmax where K is the number of emotion classes and zi is the score for class i.

3.5 Recommendation

The recommendation engine generates personalized song recommendations based on the detected emotion. Content-based filtering analyzes song features such as tempo, key, genre, mood, lyrical sentiment, and instrumentation. Collaborative filtering leverages preferences of users with similar emotional profiles. Hybrid approaches combine content-based and collaborative strategies to increase recommendation relevance and diversity. A music database stores songs tagged by emotional content and acts as the foundation for mapping emotion predictions to playlists.

4. PROPOSED ALGORITHM

4.1 Feature Extraction Using LBPH

The LBPH procedure begins by taking an input facial image and converting it to grayscale. Local binary patterns are calculated for each pixel by comparing the center pixel with its neighbors. The image is divided into regions, histograms are computed for each region, and all regional histograms are concatenated to form the final LBPH feature vector.

Step 1: Input a facial image and convert it to grayscale.

Step 2: For each pixel, compare neighboring intensities with the center pixel to produce a local binary code.

Step 3: Divide the image into spatial regions and compute a histogram of LBP codes for each region.

Step 4: Concatenate regional histograms to create the LBPH descriptor.

Step 5: Pass the descriptor to the classifier or combine it with deep features for emotion recognition.

4.2 Feature Extraction Using VGG16

The VGG16-based algorithm takes preprocessed facial images resized to 224×224 pixels. Images are normalized and passed through frozen convolutional blocks of the VGG16 network. The extracted feature maps are flattened or pooled into feature vectors. These vectors are passed to newly added dense layers and classified with softmax into seven emotions: happiness, sadness, surprise, anger, disgust, neutral, and fear.

Figure 3. Proposed system architecture using VGG16 feature extraction and softmax classification.
Figure 3. Proposed system architecture using VGG16 feature extraction and softmax classification.

5. RESULTS AND DISCUSSION

5.1 Dataset

The FER2013 dataset consists of grayscale images portraying facial expressions labeled with one of seven emotions: happy, disgust, sadness, neutral, anger, surprise, and fear. It contains 35,887 images divided into training, validation, and test sets. The dataset is used to train CNN models for emotion-based music player systems. After training, the model classifies facial expressions into emotion categories and enables the system to recommend music tailored to the detected emotional state, such as upbeat songs for happiness and calming melodies for sadness.

5.2 Experimental Setup

The experimental setup uses a computer with sufficient processing power, a webcam for image capture, speakers or headphones for audio output, and a stable internet connection to access the Spotify API. The software environment includes a Python runtime, OpenCV for image processing, TensorFlow or PyTorch for CNN implementation, and Pandas for preprocessing. GPU acceleration can improve processing speed, and additional libraries may support multimodal inputs or voice analysis.

5.3 Model Evaluation

The VGG16 model was trained over 400 epochs, with each epoch processing batches of 478 images. Hyperparameters were adjusted to optimize performance, and training was conducted on Google Colab. The model was evaluated using accuracy, recall, precision, and F1-score.

Figure 4. Proposed CNN–VGG16 performance metrics.
Figure 4. Proposed CNN–VGG16 performance metrics.

5.4 Result

The proposed CNN–VGG16 model performs well, with high recall and precision and a balanced F1-score. These results indicate effective identification of positive instances while minimizing false positives. Table 1 compares the proposed method with existing algorithms.

Table 1. Comparison of Existing and Proposed Systems
Table 1. Comparison of Existing and Proposed Systems

Algorithm Accuracy Precision Recall F1-Score CNN 57.1% 57.2% 57.1% 57.1% KNN 74.2% 73.9% 73.9% 75.1% Haar Cascade 71.8% 70.9% 70.9% 71.1% VGG16 (proposed) 85.8% 84.0% 85.0% 85.2%

6. CONCLUSION AND FUTURE WORK

6.1 Conclusion

The fusion of the VGG16 model for facial recognition with the LBPH algorithm for expression-based music playback creates a potent system that leverages computer vision to enrich user experiences. Deep learning, increasingly prominent across fields such as finance and medicine, finds significant utility in this application. The system’s ability to detect human emotions from live video inputs has implications for communication, interaction, behavioral research, and medical rehabilitation. Facial images provide non-invasive emotion detection with swift and effective results. The integration of neural networks achieved strong real-time emotionrecognition performance, underscoring the efficacy of the VGG16–LBPH approach for personalized and emotionally attuned music experiences.

6.2 Future Work

Improvements in deep learning techniques continue to enhance the accuracy and speed of facial recognition and emotion analysis, particularly on resource-limited devices. Future advancements may merge biometric modalities such as fingerprints or voice patterns with facial recognition to better understand user emotions. Such integration can support applications including therapy sessions, personalized music suggestions, augmented and virtual reality environments, and drowsiness detection for safer travel. As these technologies evolve, ethical and privacy concerns surrounding sensitive biometric data must be addressed.

FUNDING

This research received no external funding.

CONFLICTS OF INTEREST

The authors declare no conflict of interest.

References

[1]   ChaohuiLv, Shengnan Li and Linxiao Huang, “Music Emotion Recognition Based on Feature Analysis”, In proceedings 11th International Congress on Image and Signal Processing, BioMedical Engineering and Informatics (CISP-BMEI 2018) 2018.

[2]   Mehmet Bilal Er and Ibrahim Berkan Aydilek, ” Music Emotion Recognition by Using Chroma Spectrogram and Deep Visual Features ”, International Journal of Computational Intelligence Systems, pp. 1622-1634, 2019.

[3]   Harsha Vijay Bodhe, ” Movie and Music Recommendation System Based on Facial Expression ”, International Research Journal of Modernization in Engineering Technology and Science, pp. 1014-1019, Jauuary-2024.

[4]   Chukwuemeka C Atabansi, Tong Chen, Ranlei Cao and Xueming Xu, ” Transfer Learning Technique with VGG-16 for Near-Infrared Facial Expression Recognition ”, Journal of Physics: Conference Series, pp. 1- 11, 2021.

[5]   R. Venkatesan,M.Sumithra,B. Buvaneswari,R. Selvalingeshwaran. (2022). Food Ordering Systems' Newness. Journal of Cognitive Human-Computer Interaction, 4 ( 1 ), 15-20.

[6]   M. Sumithra,B. Buvaneswar,Jessica Judith S,,Dymphna Mary C,Punitha R,,Pavithraa S. "Innovation for Better Education System using Artificial Intelligence." Journal of Cognitive Human-Computer Interaction, Vol. 2, No. 1, 2022 ,PP. 19-28.

[7]   Indumathi S K, Sireesha K and Kavan MC, ” REAL TIME EMOTION BASED MUSIC PLAYER USINGCNN AR-

CHITECTURES ”, EPRA International Journal of Multidisciplinary Research (IJMR), pp.272-278, July 2022.

[8]   KrittrinChankuptarat, RaphatsakSriwatanaworachai and SupannadaChotipant, ” Emotion-Based Music Player”, In proceedings 978-1-7281-0067-8/19/$31.00 ©2019 IEEE.

[9]   Pream Anand S.,Manamalli D.,Vasanthi D.,Mythily M.,Naveen N. E.. "Optimization of Performance Attributes Using RTDA Controller for Dual CSTR." Journal of Cognitive Human-Computer Interaction, Vol. 5, No. 1, 2023 ,PP. 08-19.

[10]       Pradeep Kalansooriya, G. A. D Ganepola and T. S. Thalagala, ”Affective gaming in real-time emotion detection and music emotion recognition: Implementation approach with electroencephalogram ”, In proceedings 2020 International Research Conference on Smart Computing and System Engineering ( SCSE

), pp. 111-116, 2020

[11]       Sulaiman Muhammad, Safeer Ahmed and Dinesh Naik, ” Real Time Emotion Based Music Player Using CNN Architectures ”, In proceedings 2021 6th International Conference for Convergence in Technology (I2CT) Pune, India, pp. 1-5, 2021.

[12]       R. Manish,M. Sumithra,,Lokhitha D.,Mahalakshmi L.,Durga V.,Nirmala G.. "Accident Detection System Using GPS and GSM by IOT." Journal of Cognitive Human-Computer Interaction, Vol. 4, No. 1, 2022 ,PP. 39-51.

[13]       S. Deebika, K. A. Indira and Dr. Jesline , ” A Machine Learning Based Music Player by Detecting Emotions ”, In proceedings 2019 Fifth International Conference on Science Technology Engineering and Mathematics (ICONSTEM), pp. 196-200, 2019.

[14]       Prof.Siddaraj M G, Avais Ismail, Mohammed Aleem, Sanchitha H N and Supritha B U, ” Mood Based Music System Using Machine Learning Techniques ”, International Journal of Advances in Engineering and Management (IJAEM), pp. 1132-1136, 2022.

[15]       Shubham S. Mishra, Krutika B. Abgul, Pallavi Patil and Umashankar Singh, ” Mood Recognition and Playlist Generator ”, International Journal of Research Publication and Reviews, pp. 2326-2330, October 2023.

[16]       Gaikwad Uday Vijaysinh, Ghodake Shubham Shivaji, Mokalkar Renuka Ashok, and Jagtap HrutvikShahaji, ” Emotion based Music Recommendation System ”, International Journal of Innovative Science and Research Technology, pp. 542-545, December – 2022.

[17]       M.Sree Vani and N.Sree Divya, ” EMOTION BASED MUSIC RECOMMENDATION SYSTEM ”, nternational Journal of Creative Research Thoughts (IJCRT), pp. 697-702, June 2022.

[18]       P.VishaliM.Phil and Dr.V.Narayani, ” A Survey on Emotion-Based Music Player ”, International International Research Journal of Engineering and Technology (IRJET) , pp. 5888-5891, Mar 2020.

[19]       Meena Talele, Yash Gurnani, Hirday Rochani, Manish Patil and Kapil Soneja, ” SMART MUSIC PLAYER USING MOOD DETECTION ”, International Research Journal of Modernization in Engineering Technology and Science , pp. 2201-2207, March 2022.

[20]       Sarthak Kalpande, Ramkrishna Allampallewar, Prathamesh Vyavhare, Arun Kinwad and Saurabh Sargaiyye, ” EMOTION BASED MUSIC PLAYER ”, International Research Journal of Modernization in Engineering Technology and Science , pp. 2752-2753, May-2023.

[21]       Gayatri Pranita Prabhakar Sutar, Kashish Kumari, Ritesh Pandey, Prof. Laxmikant Malphedwar and Dr. Rajesh V. Kherde, ” A PRELIMENERY REPORT ON EMOTION BASED API MUSIC PLAYER ”, International Research Journal of Modernization in Engineering Technology and Science , pp.2716-2722, May-2022.

[22]       Manoj. K. N ,R. Adhithya. S ,A. H. Calvin ,Heaven. R. A ,K.S. Suriya. "Smart Parking System with IoT." Journal of Cognitive Human-Computer Interaction, Vol. 3, No. 2, 2022 ,PP. 08-15.

[23]       Mrs. Madhuri Gurale, Sarthak Kalpande, Ramkrishna Allampallewar, Prathamesh Vyavhare, Arun Kinwad and Saurabh Sargaiyye, ” EMOTION BASED MUSIC PLAYER: ENHANCING MUSIC EXPERIENCES ”, pp. 7594-7598, May-

2023.

[24]       Chilipiti Mounika, Dr. Srinivasan Jagannathan and V Maruthi Prasad, ” SMART MUSIC PLAYER THAT IS BASED ON REAL-TIME FACIAL EXPRESSION IN REAL TIME ”, International Journal of Creative Research Thoughts (IJCRT), pp. 451-457, August 2022.

[25]       Swarnalatha K.S ,ChitteniSai Sanjay, C Koushik, M Sai Krupananda and B M Charan, ” Emotion-Sensitive Music Player Leveraging Facial Recognition Technology ” In proceedings Emotion-Sensitive Music Player