Song Lyrics Generator with Markov Chains
Learn how to build a Flask Application that generates lyrics for any artist by scraping their top songs on Genius and feeding it into a Markov Model!Get Started
Welcome to the first advanced Python Project on Python and Flask. We’ll build our own song lyrics generator using a Markov Chain to generate lyrics from artists. We’ll start with calling Genius.com’s APIs and scrape lyric text from top songs with BeautifulSoup. After that, we’ll build our own Markov Chain class, populate our chain and dynamically generate lyrics once we’ve fed in our Artist data. We’ll tie everything together in a compact Flask application that will create and run our model, generating lyrics for any artist!
Welcome to the project!
Creating and Populating our Markov Chain Class
Create your Markov Chain class with a model to predict the sequence of possible lyrics for your artist.
Calling and Parsing Top 10 Song URLs
Explore the top ten song lyrics for an artist of interest.
Introduction to Markov Chains and Models
Get your background on the probability applications of Markov Chains.
Adding our Config and getting Artist ID
Get the details for the individual artists on the Genius website.
Setting up our Genius API and Postman
Set up the Genius API with the Postman API that will let you parse through the lyrics on the website.
Building our User Interface with Flask
Use the Flask web framework to create an aesthetic interface to view your song lyrics prediction results.
Generating Lyrics from our Markov Chain
Predict the possible lyrics for your artist from the Markov stochastic model you built.
Scraping Lyric Text from Top Songs
For each top song, scrape through the words in the lyrics with the BeautifulSoup text parser.
Beautifying and Final Touches
Complete the finishing touches to your song lyrics generator user interface!