Skip to content

neoki07/generating-piano-music-with-transformer

Repository files navigation

Generating Piano Music with Transformer

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

Getting Started

You must have Docker installed on your computer.

  1. Clone the repository
git clone https://github.com/ot07/generating-piano-music-with-transformer.git
cd generating-piano-music-with-transformer
  1. Build a docker image using the Dockerfile
docker build -t generating-piano-music-with-transformer .
  1. Run the script using the docker image created in the previous step

Generate from Scratch

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

Generate Continuation

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>

Generate Accompaniment for Melody

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>

Inspiration

This is inspired by the following repository:

About

Building Music Transformer environment with Dockerfile and Poetry

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published