Lyricized is a website that generates song lyrics in a given genre based on the songs from popular artists within said genre. The Python-based website contains a "demo mode" that runs on the CS50 IDE using Flask, and the program can be run in its full power elsewhere. The following submission contains many files, some of which were used to acquire and hard-code data, while others are necessary for running the website. On the website, the user has the option to pick one of three music genres: country, hip-hop, or pop. They will be directed to a page of lyrics to a plausible (but fake) song in that genre. In demo mode, the webpage randomly chooses lyrics from a pre-generated selection of songs. If not in demo mode, a user could train the RNN and generate songs live.
data/
contains text files of original lyrics scraped from Geniusdemo_songs/
contains 50 pre-generated songs per genremodels
contains trained models (ckpt files) for each genre based ondata/
static/
contains the CSS stylesheettemplates/
contains HTML templates for the index and song pagesapplication.py
runs the web application using Flasklyrics.py
scrapes Genius for the lyrics of top artists, given their namesrequirements.txt
contains required dependencies for running programrnn.py
contains a recurrent neural network that trains models and generates lyrics based on said models (unused in demo mode)song.txt
contains the generated song output fromrnn.py
(unused in demo mode)
- Demo Mode (Intended to be run on CS50 IDE)
- Set
DEMO_MODE = True
inapplication.py
- Execute
flask run
in terminal window to start website - Select genre from home page, view generated lyrics (randomly selected from 50 pre-generated songs)
- Set
- Not Demo Mode (Cannot be run on CS50 IDE)
- Set
DEMO_MODE = False
inapplication.py
- Training models: set
country_model_trained = False
, orhiphop_model_trained = False
, orpop_model_trained = False
in order to retrain models in specific genre.- Running the RNN will require the installation of TensorFlow (see here for more info).
- Models perform better given more data and more training iterations
- Generating songs: generated lyrics using trained models will be stored in
song.txt
- Execute
flask run
in terminal window to start website - Select genre from home page, view generated lyrics
- Set
- Other Notes
- Running
lyrics.py
:- Set
CLIENT_ACCESS_TOKEN
to your Genius API access token (available here) - Execute
python lyrics.py
in terminal window in order to gather all lyrics for top ten artists in each genre (country, hip hop, pop)- Top ten artists are hardcoded in
country_artists
,hip_hop_artists
, andpop_artists
arrays, and can be updated accordingly
- Top ten artists are hardcoded in
lyrics.py
has already been executed; lyric files are available indata/
folder
- Set
- Running
Much of the code is inspired by several other projects, without which this project would not be possible.
In lyrics.py
:
get_data
,get_artists
, andget_songs
were all inspired by this GitHub post- The scraping system in
get_lyrics
is based on code from this website.
In rnn.py
:
- The code is heavily inspired by this GitHub post
- We learned about RNN processing here
The web application is based on the distribution code from Problem Set 7.
Additional thanks to our TFs, Derek Wang and Vojta Drmota, and the entire CS50 staff at Harvard.
Created by Cassandra Kane '21 and Samantha Hung '20 for Computer Science 50 at Harvard College, Fall 2017.