I was working on optimization, but my primary goal was to upgrade the code for compatibility with the actual versions of Keras and Tensorflow. Im sorry to say, eventually dropped the development because of a problem with the structure and generation in the nn (have no resources to make tests), my (2010) computer was not able to run tests and had no access to better equipment.
Creators of the initial code:
- https://github.com/MattVitelli/GRUV
- https://github.com/unnati-xyz/music-generation
Using it as a base for university project... I'll upload it when finished.
Algorithmic music generation using RNN(Recurrent Neural Networks)
Language used : Python 2.7
The following packages have to be installed before running this code:
- Keras version 0.1.0 with TensorFlow as the backend.
- NumPy and SciPy for various mathematical computation on tensors.
- Matplotlib for visualizing the input.
- LAME and SoX to convert mp3 files into other formats such as wav.
Type the following command into the terminal:
python convert_directory.py
This converts mp3 into mono files and then into WAV file, which is stored in the form of np-tensors. These np-tensors are given as input to our LSTM model. By the end of this one can find these 2 files generated "YourMusicLibraryNP_x.npy", "YourMusicLibraryNP_y.npy". "YourMusicLibraryNP_x.npy" contains the input sequence for training and "YourMusicLibraryNP_y.npy" contains the same sequence as that of input sequence but shifted by one block.
Type the following command into the terminal:
python train.py
This builds a LSTM model that generates a sequence of notes which is compared against the expected output and the errors are back-propagated, thus adjusting the parameters learnt by the LSTM. You can change the number of Iterations, number of epochs per iteration and batch size by adjusting the following parameters "num_iters", "epochs_per_iter", "batch_size" respectively in train.py.
Now that you've finished training the model, its time to generate some music:) Type the following command in your terminal':
python generate.py
The generated WAV file is stored in a file named generated_song.wav.