Giant Music Transformer as a PyPi package
pip install giantmusictransformer
(Optional) FluidSynth for MIDI to Audio functinality
sudo apt-get install fluidsynth
Windows (with Chocolatey)
choco install fluidsynth
import giantmusictransformer as gmt
# Load desired Giant Music Transformer model
# There are several to choose from...
model = gmt.load_model('medium')
# Get sample seed MIDI path
sample_midi_path = gmt.get_sample_midi_files()[6][1]
# Load seed MIDI
input_tokens = gmt.midi_to_tokens(sample_midi_path)
# Generate seed MIDI continuation
output_tokens = gmt.generate(model, input_tokens, 600, return_prime=True)
# Save output to MIDI
gmt.tokens_to_midi(output_tokens[0])