Downloads · 30 days
191
5% of all-time downloads
musiclang/musiclang-4k
musiclang-4k is a text generation model from musiclang. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as gpl-3.0.
MusicLang Predict model =======================
Downloads · 30 days
191
5% of all-time downloads
All-time downloads
3.6K
Public
Parameters
21M
224 MB on disk
Likes
22
Public
Click a slice to open those files.
.onnx140 MB · 62%
From the Hugging Face model README

MusicLang Predict is a model for creating original midi soundtracks with generative AI model.
It can be used for different use cases :
To solve template generation use cases, we provide an interface to create a template from an existing midi file.
To make the prediction we have an inference package available here : MusicLang Predict which is based on the musiclang language : MusicLang.
Install the musiclang-predict package with pip :
pip install musiclang-predict
from musiclang_predict import predict, MusicLangTokenizer
from transformers import GPT2LMHeadModel
# Load model and tokenizer
model = GPT2LMHeadModel.from_pretrained('musiclang/musiclang-4k')
tokenizer = MusicLangTokenizer('musiclang/musiclang-4k')
soundtrack = predict(model, tokenizer, chord_duration=4, nb_chords=2)
soundtrack.to_midi('song.mid', tempo=120, time_signature=(4, 4))
from musiclang_predict import midi_file_to_template, predict_with_template, MusicLangTokenizer
from transformers import GPT2LMHeadModel
# Load model and tokenizer
model = GPT2LMHeadModel.from_pretrained('musiclang/musiclang-4k')
tokenizer = MusicLangTokenizer('musiclang/musiclang-4k')
template = midi_file_to_template('my_song.mid')
soundtrack = predict_with_template(template, model, tokenizer)
soundtrack.to_midi('song.mid', tempo=template['tempo'], time_signature=template['time_signature'])
See : MusicLang templates For a full description of our template format. It's only a dictionary containing information for each chord of the song and some metadata like tempo. You can even create your own without using a base midi file !
from musiclang_predict import midi_file_to_template, predict_with_template, MusicLangTokenizer
from transformers import GPT2LMHeadModel
from musiclang import Score
# Load model and tokenizer
model = GPT2LMHeadModel.from_pretrained('musiclang/musiclang-4k')
tokenizer = MusicLangTokenizer('musiclang/musiclang-4k')
template = midi_file_to_template('my_song.mid')
# Take the first chord of the template as a prompt
prompt = Score.from_midi('my_prompt.mid', chord_range=(0, 4))
soundtrack = predict_with_template(template, model, tokenizer,
prompt=prompt, # Prompt the model with a musiclang score
prompt_included_in_template=True # To say the prompt score is included in the template
)
soundtrack.to_midi('song.mid', tempo=template['tempo'], time_signature=template['time_signature'])
If you want to help shape the future of open source music generation, please contact us
The MusicLang predict package (this package) and its associated models is licensed under the GPL-3.0 License. The MusicLang base language (musiclang package) is licensed under the BSD 3-Clause License.