showurl / music_gen_deep_learning

Music Generation using Deep Learning in Python with Tensorflow & Keras

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Music Generation Using Deep Learning

Sequence generation using LSTM
This was developped as part of my bachelor thesis at The University of Manchester

@simeonedef License MIT Python 3.6 Release date: june 2019

Requirements

  • Python 3.6
  • Tensorflow==1.12.0
  • Keras==2.2.4
  • H5py==2.9.0
  • Music21
  • PyGame and PyGame Menu (if you want to use generate_GUI.py)

More information in the requirements.txt file

Setting up the project

To install all the required packaged simply run from the project's root directory:

pip install -r requirements.txt

See next steps to run the model and generate some music!

Usage example

Training the model

You need to first train the model which you can do by running one of the training scripts like so:

python train_single.py

if you to have only a single class as output, which means only one note playing at a time; otherwise:

python train_multiclass.py

if you want to take into account multiple notes being played at once.

Both training scripts will use every midi file in ./midi to train the network. Currently the directory contains all the pieces from Bach's Well-Tempered Clavier II as well as some additional files that you can decide to use if you enable their usage in the train_single.py file.

Generating music

Once you have trained the network, you will have a set of weights which you can use instead of the weights.hdf5 file that comes in the repository. You can then generate using the trained network using generate.py like so:

python generate.py

The output will be test_output.mid. There is already an included midi file as an example of what the network can generate.

Additionally there is a GUI that you can use that will generate and play the music provided you have installed PyGame and PyGameMenu which you can run like so:

python generate_GUI.py

Going forward

Below is a list of a few more things I would like to implement in this project:

  • finishing up train_output.py and getting a set of weights to generate music with multiple notes playing at once (in another private repo)
  • making multiple set of weights for different genres of music
  • implementing an option to generate fully random music
  • turning it into a web app to be accessible from everywhere Click here !

About

Music Generation using Deep Learning in Python with Tensorflow & Keras

License:MIT License


Languages

Language:Python 100.0%