This is a ported script from the original Music Transformer notebook. Also included is a Dockerfile that makes it easy build the environment to run the script.
This project is inspired by this repository, but differs in the following:
- Follows newer versions of notebook (e.g. library versions used)
- Easily create an execution environment with Dockerfile and Poetry
- Export as wave file in addition to MIDI file
- Only the original notebook generation method is implemented
You must have Docker installed on your computer.
- Clone the repository
git clone https://github.com/ot07/generating-piano-music-with-transformer.git
cd generating-piano-music-with-transformer
- Build a docker image using the
Dockerfile
docker build -t generating-piano-music-with-transformer .
- Run the script using the docker image created in the previous step
You can generate a piano performance from scratch using the unconditional model.
docker run -it --rm -v ${PWD}/output:/output generating-piano-music-with-transformer \
python generate_from_unconditional_model.py --output_dir=/output
By specifying a primer MIDI file in --primer
argument,
you can generate a piano performance that is a continuation of the chosen primer.
docker run -it --rm -v ${PWD}/output:/output generating-piano-music-with-transformer \
python generate_from_unconditional_model.py --output_dir=/output --primer=<primer midi file>
By specifying a melody MIDI file in --melody
argument,
you can generate a piano performance consisting of the chosen melody plus accompaniment.
docker run -it --rm -v ${PWD}/output:/output generating-piano-music-with-transformer \
python generate_from_melody_conditioned_model.py --output_dir=/output --melody=<melody midi file>
This is inspired by the following repository: