SymponyNet is an open-source project aiming to generate complex multi-track and multi-instrument music like symphony. Our method is fully compatible with other types of music like pop, piano, solo music..etc.
Have fun with SymphonyNet !!We highly recommend users to run this project under conda environment.
conda create -n your_env_name python=3.8
conda activate your_env_name
cd path_to_your_env
git clone this_project
cd SymphonyNet
cat requirements.txt | xargs -n 1 -L 1 pip install
The reason for using cat requirements is we find out the pytorch-fast-transformers package needs to be built upon torch, directly pip install requirements may cause pytorch-fast-transformers built error.
Note: Building pytorch-fast-transformers takes a while, please wait patiently.
- Put your midi files into
data/midis/
- Run
python3 src/preprocess/preprocess_midi.pyunder project root path
Quick note: The preprocess_midi.py multi-process all the Midis and convert them into a raw_corpus.txt file. In this
file, each line of encoded text represents a full song.
- Run
python3 src/preprocess/get_bpe_data.pyif you want to train the model with Music BPE. More details about fast BPE implementation could be found hereMusic BPE. - Set
BPE=1inconfig.shfile
Note: We only provide music_bpe_exec file for linux system usage, if you are using MacOS or Windows, please re-compile
the music_bpe_exec file here by following the instruction.
- Run
python3 src/fairseq/make_data.pyto convert theraw_corpus.txtinto binary file for fairseq and createfour vocabulariesmentioned in the paper.
- Run
sh train_linear_chord.shto train your own model!
- Put your checkpoint file or download our pretrained model into
ckpt/ - Run
python3 src/fairseq/gen_batch.py test.mid 5 0 1to generate one symphony MIDI conditioned on the first 5 measures of test.mid, with no constraints of chord progression. - Or replace
test.midwith your own prime MIDI and set how many measures of chords from the prime MIDI you may want to keep. - We provide a Google Colab file
play_symphonynet.ipynb, where you could follow the generation guide.
SymphonyNet is released under the MIT license
