Music Generator Project Structure
This week I transferred my code out of a bunch of experimental Jupyter Notebooks, and organized it into the final structure that I’ll open source next week. It was admittedly an unglamorous week, but now everything is simpler and more robust to run. Not a lot has changed fundamentally, but now I’m able to quickly launch a bunch of AWS training runs in parallel, to compare hyperparameter choices and encoding styles.
I’m also excited to announce I’ve been invited to give a concert in a few weeks where I’ll be playing a few generated samples live, so I’ll post videos to that soon. Because of this, I’ve returned to focusing on generating piano solo music.
- data-collector.py – a quick script that pulls midi files from Classical Archives (you first need to register and make an account with the website)
Midi to Text Encoding
- midi-to-encoding.py – uses MIT’s music21 to translate each midi file to a music21 stream, and then translates this stream into each of my different encoding formats (notewise and chordwise, with different note ranges and sampling frequencies)
- make_test_train.py – copies text files generated by midi-to-encoding.py and randomly assigns them to train and test folders (the user can set which encoding to use, as well as what percentage to assign to test/train)
- train.py – creates an AWD-LSTM model (using the FastAI library), and trains it using the files created by make_test_train.py Periodically, model checkpoints are saved inside the folder data/models
- generate.py – creates a batch of musical text generations, and then outputs them to midi, wav, and mp3 formats. Generation can be prompted by silence, a random training or test set clip, or a user-specified clip.
- critic.py – trains a music critic (to determine real vs. fake music samples), and outputs a realness score for any input music sample
- composer_classifier.py – trains a critic to determine who the composer is for any given music sample
This week I’ll be training several generator models in parallel, and I’ll sort out hosting a model and webpage on AWS. I’m aiming to create a page where you can generate new composition samples at the click of a button.