The Song Lyrics Sentiment and Emotion Analyzer is a Flask-based web application that performs natural language processing (NLP) on song lyrics to determine their sentiment polarity, emotional composition, and overall mood.
By combining VADER Sentiment Analysis, TextBlob, and an emotion lexicon, this project provides a detailed interpretation of lyrical content β revealing whether a song is happy, sad, neutral, or emotionally complex.
Key Features
πΆ Song Sentiment Detection:
Uses the VADER SentimentIntensityAnalyzer to classify lyrics as Positive, Negative, or Neutral based on polarity scores.π¬ Emotion Analysis:
Reads an externalemotion.csvfile mapping words to emotions (like joy, anger, fear, etc.) and visualizes the emotional distribution using a matplotlib bar chart.π§ Text Preprocessing:
Converts lyrics to lowercase
Removes punctuation
Removes English stopwords
Tokenizes and lemmatizes words for clean analysis
π Visualization:
Displays a colorful bar graph showing the frequency of detected emotions in the song.π Mood Classification:
Based on TextBlobβs polarity, the app categorizes the song as:Very Sad π₯Ί
Sad π₯
Cheerful π
Happy π
Neutral π
π₯οΈ Web Interface:
A user-friendly Flask frontend allows users to input a song title and lyrics, then view a detailed sentiment report.
Technologies Used
Python (Core Language)
Flask (Web Framework)
NLTK (Tokenization, Stopwords, Lemmatization)
TextBlob (Polarity & Sentiment Analysis)
VADER Sentiment Analyzer (Fine-grained Sentiment Scoring)
Matplotlib (Data Visualization)
HTML/CSS (Frontend templates:
index.html,submit.html)
Workflow
User enters the song title and lyrics in the input form.
The app cleans and preprocesses the lyrics.
Sentiment and emotion analysis are performed using NLP libraries.
A compound sentiment score and emotion frequency graph are generated.
Results are displayed in the output page, showing:
Song sentiment summary
Polarity percentage
Dominant and weakest emotions
Overall mood classification
Sample Output
Compound Sentiment Score: 78.2%
Detected Sentiment: Positive π
Dominant Emotion: JOY
Weakest Emotion: FEAR
Song Mood: Happy Song π
Use Cases
Music emotion research
Lyric-based mood categorization
Music recommendation systems
Educational NLP demonstration
Future Enhancements
Integration with APIs (e.g., Genius API) to fetch lyrics automatically
More detailed emotion lexicon with intensity scores
Word cloud visualization for emotional words
Model-based classification using deep learning