Coder Social home page Coder Social logo

harmonizer's Introduction

MelTS is an automatic harmonization system that creates multi-part arrangements in the style of the data on which it is trained. The system approaches the problem of harmonization from a machine tranlsation perspective, modeling the melody of a song as the source language and each harmony as a target language. Below is a step-by-step guide to training the models and generating a simple composition.

Before using MelTS, first set the PYTHONPATH environment variable to include MelTS with the following command:

echo PYTHONPATH=$PYTHONPATH:/path/to/melts/evaluate:path/to/melts/train:path/to/melts/compose:path/to/melts/utils

MelTS relies on language and translation models to create compositions. The system requires a language model for each harmony voice to be generated in addition to a translation model between the melody voice and every harmony voice and translation models between each of the harmony voices. The models are saved in text files after they are generated so that they can be used repeatedly for future compositions. For example models, see the models/bach/major directory which contains all the translation and language models required to create, from a given Soprano part, the Alto, Tenor, and Bass parts in the major mode and in the style of Bach.

All scripts related to training the models are located in the train/ directory.

To train a MelTS translation model from the Soprano part to the Bass part, the following basic command can be used:

python translation_model_generator.py --melody=Soprano --harmony=Bass --training_paths=major_bach_training_paths.txt --output_dir=/path/of/output/directory

Similarly, to train a MelTS language model for the Bass part, use the command:

python language_model_generator.py --part_name=Bass --training_paths=major_bach_training_paths.txt --output_dir=/path/of/output/directory

After the models are trained, you can train weights for the respective models by typing the command:

python weight_trainer.py --training_songs=major_bach_optimization_paths.txt --model_directory=/path/to/models --melodies=Soprano --harmony=Bass

weight_trainer.py is an implementation of the Powell algorithm. You can optimize on the harmonization from multiple melodies to one harmony, although optimizing for just one melody to one harmony seems to suffice. It is recommended that you train the weights on a held-out set of data. Trained weights usually result in a higher quality system based on overall perplexity scores. However, the system can run without trained weights, in which case each model will be weighed equally.

MelTS offers a perplexity metric calculator to evaluate the trained models. The script that calculates these scores is located in the evaluate/ directory. To get perplexity scores for your models over a held out test set, use the following command:

python evaluator.py major_bach_test_paths.txt --melody=Soprano --harmonies=Bass --directory=/path/to/models --tm_phrase_weight=1 --tm_note_weight=1 --lm_weight=1

Finally, compose/composition.py is used to create a full composition based on a melody. Run composition.py with the following command:

python composition.py /path/to/melody --melody_name=Soprano --harmony_names=Bass --directory=/path/to/models --output_file=mycomposition.xml

The composition script accepts a path to a music xml file containing the melody line to be harmonized. The name of the melody voice and the harmony voices to be generated are also specified. The final composition will be saved to mycomposition.xml.

harmonizer's People

Contributors

nikkil331 avatar rigeljs avatar

Stargazers

Mark Godfrey avatar

Watchers

Chris Callison-Burch avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.