File size: 3,002 Bytes
97b0180 22239bc 97b0180 25d4228 97b0180 2166e27 97b0180 25d4228 97b0180 2166e27 6481ae3 2166e27 97b0180 32c8335 97b0180 f8addc7 1aa19e2 97b0180 f8addc7 97b0180 f8addc7 97b0180 0389810 97b0180 0389810 97b0180 dc8cdc4 97b0180 22239bc 97b0180 22239bc bfec998 22239bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
---
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 ! |