This repository contains code for generating new music using Generative Adversarial Networks (GANs). GANs are a type of deep learning model that can learn to generate new data that resembles the training data. In this case, we use GANs to generate music sequences based on existing MIDI files.
create_generator_model.py
: This script contains the implementation of a GAN for generating music. It defines the generator and discriminator models, trains the GAN, and saves the trained models.discriminator_model.h5
: This file contains the saved weights of the trained discriminator model.gan_final.mid
: A MIDI file containing music generated by the trained GAN.generator_model.h5
: This file contains the saved weights of the trained generator model.play_midi.py
: A script to play the generated MIDI file and hear the music.
-
Training the GAN: If you want to train the GAN on your own MIDI dataset, run the
create_generator_model.py
script. This script will parse the MIDI files in thearchive
folder, preprocess the data, and train the GAN to generate new music. After training, the generator and discriminator models will be saved ingenerator_model.h5
anddiscriminator_model.h5
, respectively. -
Generate New Music: To generate new music using the trained generator model, run the
generate_music.py
script. This script loads the generator model, generates random noise as input, and generates a new music sequence. The resulting music sequence will be saved asgan_final.mid
. -
Play the Generated Music: To listen to the generated music, run the
play_midi.py
script. This script will play thegan_final.mid
file and allow you to hear the music.
The code in this repository uses Python and the following libraries:
- TensorFlow
- Keras
- music21
You can install the required dependencies using pip
:
pip install tensorflow keras music21
Feel free to contribute to this project by opening issues or submitting pull requests. If you have ideas for improvements or new features, we'd love to hear from you!
This repository is licensed under the MIT License. See the LICENSE file for more details.