musiclang / README.md
floriangardin's picture
Update README.md
592e727
metadata
license: bsd-3-clause
widget:
  - text: (I%I.M)(piano__0=s0,piano__1=s2,piano__3=s4)
    example_title: Continue a C-major chord

Musiclang LLM

Check https://github.com/MusicLang/musiclang to use this model in your musical compositions

MusicLang LLM is a language model based on top of the musiclang symbolic tonal music language. Is is used to predict new music from an existing score.

How to use

Install musiclang package in python :

pip install musiclang

Predict some music from a given prompt written with musiclang :

from musiclang.library import *
from musiclang import Score

# Some random bar of chopin op18 Waltz
score = ((V % III.b.M)(
    piano__0=s0 + s2.e.mp + s3.e.mp, 
    piano__4=s0.e.o(-2).p + r.e + s0.ed.o(-1).mp + r.s, 
    piano__5=r + s4.ed.o(-1).mp + r.s, 
    piano__6=r + s6.ed.o(-1).mp + r.s)+ 
(V['7'] % III.b.M)(
    piano__0=s2.ed.mp + r.s, 
    piano__2=s4.ed.mp + r.s, 
    piano__4=s6.ed.o(-1).mp + r.s, 
    piano__5=s0.ed.o(-1).mp + r.s, 
    piano__6=s4.ed.o(-1).mp + r.s))

# Predict the next two chords of the score using huggingface musiclang model
predicted_score = score.predict_score(n_chords=2, temperature=0.5)
# Save it to midi
predicted_score.to_midi('test.mid')