--- widget: - text: CHORD_CHANGE example_title: Predict chord progression --- MusicLang Chord Predictor model =============================== ![MusicLang logo](https://github.com/MusicLang/musiclang/blob/main/documentation/images/MusicLang.png?raw=true "MusicLang") MusicLang Chord Predictor is a model for creating original chord scale progressions in the musiclang format with generative AI model. It can be used for different use cases : - Predict a chord progression from scratch (a fixed number of chords) - Continue a chord progression (using a MusicLang prompt) If you are only looking to generate chord progressions in an easily readable format, consider using [our text chord predictor](https://huggingface.co/musiclang/text-chord-predictor) To make the prediction we have an inference package available here : [MusicLang Predict](https://github.com/MusicLang/musiclang_predict) which is based on the musiclang language : [MusicLang](https://github.com/MusicLang/musiclang). Installation ------------ Install the musiclang-predict package with pip : ```bash pip install musiclang-predict ``` How to use ? ------------ 1. Generate a 4 chords progression in few lines : ```python from musiclang_predict import predict_chords, MusicLangTokenizer from transformers import AutoModelForCausalLM, AutoTokenizer from musiclang.library import * # Load model and tokenizer model = AutoModelForCausalLM.from_pretrained('musiclang/musiclang-chord-v2-4k') tokenizer = AutoTokenizer.from_pretrained('musiclang/musiclang-chord-v2-4k') soundtrack = predict_chords(model, tokenizer, nb_chords=4, temperature=1.0) # Give the chord a simple voicing (closed position chord) soundtrack = soundtrack(b0, b1, b2, b3) # Save it to midi soundtrack.to_midi('song.mid', tempo=120, time_signature=(4, 4)) ``` 2. Use a prompt ```python from musiclang_predict import predict_chords, MusicLangTokenizer from transformers import AutoModelForCausalLM, AutoTokenizer from musiclang.library import * prompt = (I % I.M) + (V % I.M)['6'].o(-1) # Load model and tokenizer model = GPT2LMHeadModel.from_pretrained('musiclang/musiclang-chord-v2-4k') tokenizer = AutoTokenizer.from_pretrained('musiclang/musiclang-chord-v2-4k') soundtrack = predict_chords(model, tokenizer, nb_chords=4, prompt=prompt) # Give the chord a simple voicing (closed position chord) soundtrack = soundtrack(b0, b1, b2, b3) # Save it to midi soundtrack.to_midi('song.mid', tempo=120, time_signature=(4, 4)) ``` Contact us ---------- If you want to help shape the future of open source music generation, please contact [us](mailto:fgardin.pro@gmail.com) License ======== This model is free to use for research and open source purpose only. Please credit me (Florian GARDIN) and musiclang if you do so. If you would like to use this in a commercial product please contact [us](florian.gardin@musiclang.io) to discuss licensing terms and potential integration in your product. I am looking forward to hearing about your project !