Synsong

A prompt-based playlist generator!


TLDR:

I just somewhat finished the beta of a project (synsong) to practice NLP, Python, and API skills. Right now, you can input genre, popularity, and a natural language prompt (such as a sentence, quote, or paragraph), and it will create a playlist based on matches with the lyrics, song title, and artist name with the prompt. Eventual goals are to practice model training to auto-detect genres, do some topic modeling with larger prompts, and maybe even have an option for mood.


The Beginnings

The beginnings of synsong have been super fun. It started with the idea, to make a playlist from a sentence, and ended with a whole bunch of other playlist customizations, such as genre and popularity. I made the backend first, and then also created the website.

The Backend

The backend is written in Python, and uses spaCy for all the NLP. I started out by getting the title, spaCy gets the noun phrases by looking at dependencies (nsubj or pobj) or heads (lemma_ == "be"). The constituents that are searched in the lyrics are found using spaCy's .noun_chunks function. For both the title and the constituents, a random sample is taken (1 for the title and 5 for the constituents).

The constituents are then put in a series of lists with differing amounts of items to ensure that relevant but enough results come up.

# prompt: Potatoes are great food for worms and bugs in the ground.

[['potato', 'great food', 'worm', 'bug', 'ground'], ['great food', 'bug', 'ground'], ['worm', 'bug', 'ground'], ['potato', 'great food', 'worm', 'bug'], ['potato', 'worm', 'bug', 'ground'], ['great food', 'worm', 'bug', 'ground'], ['potato'], ['great food'], ['worm'], ['bug'], ['ground']]

The lists are then formatted and searched through the Musixmatch database with the inputted genre and popularity filters. If there's more than 30 songs, the code will just take the first 30, which are probably the most relevant ones due to the ordering of the search.