Inspiration

In the fast-paced modern world, too often do thoughts and emotions go unprocessed. Moody.ai strives to promote mental health, foster personal growth and encourage self-discovery through journal entries and personalized music experiences.

What it does

Users can freely navigate the user-friendly interface through these tabs...

Login: Connect to Spotify Account using Spotify OAuth authentication.

Journal: Jot down feelings, capture thoughts and record daily events. Users can save, edit and submit their journal entries at any time of the day including submitting ones for previous days. Submitting an entry will generate a custom mood based playlist for you and a themed quote for your day!

Calendar: Monthly overview that allows users to click on any day to display the corresponding journal entry and their mood for the day.

How we built it

Flask web application connected to a SQLite database.

Playlist generation done through a sentiment analysis model built with sklearn logistic regression in order to classify user songs.

Mood leverage of journal entries and quote output done with OpenAI API

Front-end: Prioritizes aesthetics and accessibility. Cohesive and interactive all-in-one hub. Implemented user inputs, functional save/submit/edit buttons, iframes, auto-scale textbox, calendar, navigation tabs in a creative way to offer a pleasant interface.

Cohesion between different tabs Despite having different features, we wanted Moodify.ai to be consistent and smart in its design choices throughout the different tabs. Therefore, we implement a navigation bar for the user to easily access all aspects of our project.

Back-end: Flask-based application seamlessly connects with Spotify API, dynamically curating playlists based on user moods using machine learning predictions, while also incorporating a personalized journal system for users to document and reflect on their experiences.

Training the sentiment analysis model In order to personalize created playlists to a user's listening history, we trained a logistic regression model in order to classify songs as one of 4 basic types of songs: angry, relaxed, happy, sad based on 4 different features of the songs including valence, loudness, danceability, energy. The model would return a mood given a Spotify track and would judge it based on these features.

Firstly to create the training set, we took an existing CSV of 2000 Last.fm songs that have been tagged with the 4 moods. Using this we created a python script that looked up those same songs in Spotify, pulled their features (valence, loudness, etc.) using the Spotify APIand saved it to a training set. This process took around a half hour due to the rate limit of the developer API. After testing out the training data on various models in Sklearn, we chose the logistic regression model as it had the best performance overall. Given more time, we could create a larger and more comprehensive training set.

Challenges we ran into

Working with AI Having a good understanding of how the AI answers to our specific prompts was very important to us to ensure relevant song and quote generation. We used the playground to experiment with and handle edge cases.

Routing and APIs While having worked in flask before, routing was particularly challenging this time, as we were working simultaneously with multiple different APIs all with their own endpoints that we had to reach through redirects and return URLs. We ran into many issues such as OpenAI keys expiring quickly and Spotify's OAuth2 authentication process due to Spotify's rate limit on developer app users and API calls

Queries for the databases We encountered a minor issue in our process, where queries for adding journal entries to our database were causing errors. This was due to the complexity of ensuring a correct entry date that wasn't null, along with a journal entry text that would not result in null input. Since the journal had empty spaces within lines that were not occupied, we needed to address the 'not null' constraint by appending only lines with text to a list. To resolve the entry date problem, we incorporated a default entry date of the present date and inserted it into the database before checking if an entry with the associated date already existed.

What's next for Moody.ai

Implement facial analysis to leverage mood using the OpenAi API.

Flag the different moods into categories to have a better overview of the month.

Make the web app mobile accessible for users to write entries on the go during the day.

Implement a bigger database with wider range of emotional tag lines to pull from for more tailored playlists.

Optimize run-time: generating the songs is slow as it queries over the 2000 songs.

Built With

Share this project:

Updates