Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: arxiv.org, springer.com, acm.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.5%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: miniTalDev
- License: mit
- Language: Python
- Default Branch: main
- Size: 2.66 MB
Statistics
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
MidiTok
Python package to tokenize MIDI music files, presented at the ISMIR 2021 LBD.

Using Deep Learning with symbolic music ? MidiTok can take care of converting (tokenizing) your MIDI files into tokens, ready to be fed to models such as Transformer, for any generation, transcription or MIR task. MidiTok features most known MIDI tokenizations (e.g. REMI, Compound Word...), and is built around the idea that they all share common parameters and methods. It supports Byte Pair Encoding (BPE) and data augmentation.
Documentation: miditok.readthedocs.com
Install
shell
pip install miditok
MidiTok uses MIDIToolkit, which itself uses Mido to read and write MIDI files, and BPE is backed by Hugging Face 🤗tokenizers for super-fast encoding.
Usage example
The most basic and useful methods are summarized here. And here is a simple notebook example showing how to use Hugging Face models to generate music, with MidiTok taking care of tokenizing MIDIs.
```python from miditok import REMI, TokenizerConfig from miditok.utils import getmidiprograms from miditoolkit import MidiFile from pathlib import Path
Creating the tokenizer's configuration, read the doc to explore other parameters
config = TokenizerConfig(nbvelocities=16, usechords=True)
Creates the tokenizer and loads a MIDI
tokenizer = REMI(config) midi = MidiFile('path/to/your_midi.mid')
Converts MIDI to tokens, and back to a MIDI
tokens = tokenizer(midi) # calling it will automatically detect MIDIs, paths and tokens before the conversion convertedbackmidi = tokenizer(tokens, getmidiprograms(midi)) # PyTorch / Tensorflow / Numpy tensors supported
Converts MIDI files to tokens saved as JSON files
midipaths = list(Path("path", "to", "dataset").glob("*/.mid")) dataaugmentationoffsets = [2, 1, 1] # data augmentation on 2 pitch octaves, 1 velocity and 1 duration values tokenizer.tokenizemididataset(midipaths, Path("path", "to", "tokensnoBPE"), dataaugmentoffsets=dataaugmentation_offsets)
Constructs the vocabulary with BPE, from the tokenized files
tokenizer.learnbpe( vocabsize=500, tokenspaths=list(Path("path", "to", "tokensnoBPE").glob("*/.json")), startfromempty_voc=False, )
Saving our tokenizer, to retrieve it back later with the load_params method
tokenizer.save_params(Path("path", "to", "save", "tokenizer.json"))
Converts the tokenized musics into tokens with BPE
tokenizer.applybpetodataset(Path('path', 'to', 'tokensnoBPE'), Path('path', 'to', 'tokens_BPE')) ```
Tokenizations
MidiTok implements the tokenizations: (links to original papers) * REMI * REMI+ * MIDI-Like * TSD * Structured * CPWord * Octuple * MuMIDI * MMM
You can find short presentations in the documentation.
Limitations
Tokenizations using Bar tokens (REMI, Compound Word and MuMIDI) only considers a 4/x time signature for now. This means that each bar is considered covering 4 beats. REMI+ and Octuple support it.
Contributions
Contributions are gratefully welcomed, feel free to open an issue or send a PR if you want to add a tokenization or speed up the code. You can read the contribution guide for details.
Todos
- Option to place
Programtokens before note tokens for TSD, "vanilla" REMI, MIDI-Like and Structured; - Extend Time Signature to all tokenizations;
- Control Change messages;
- Option to represent pitch values as pitch intervals, as it seems to improve performances;
- Speeding up MIDI read / load (using a Rust / C++ io library + Python binding ?);
- Data augmentation on duration values at the MIDI level.
Citation
If you use MidiTok for your research, a citation in your manuscript would be gladly appreciated. ❤️
MidiTok paper
bibtex
@inproceedings{miditok2021,
title={{MidiTok}: A Python package for {MIDI} file tokenization},
author={Fradet, Nathan and Briot, Jean-Pierre and Chhel, Fabien and El Fallah Seghrouchni, Amal and Gutowski, Nicolas},
booktitle={Extended Abstracts for the Late-Breaking Demo Session of the 22nd International Society for Music Information Retrieval Conference},
year={2021},
url={https://archives.ismir.net/ismir2021/latebreaking/000005.pdf},
}
The BibTeX citations of all tokenizations can be found in the documentation
Acknowledgments
Special thanks to all the contributors. We acknowledge Aubay, the LIP6, LERIA and ESEO for the initial financing and support.
Owner
- Name: MiniTalDev
- Login: miniTalDev
- Kind: user
- Repositories: 1
- Profile: https://github.com/miniTalDev
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Fradet" given-names: "Nathan" orcid: "https://orcid.org/0000-0003-4729-570X" - family-names: "Briot" given-names: "Jean-Pierre" orcid: "https://orcid.org/0000-0003-1621-6335" - family-names: "Chhel" given-names: "Fabien" orcid: "https://orcid.org/0000-0003-2224-8296" - family-names: "El Fallah Seghrouchni" given-names: "Amal" orcid: "https://orcid.org/0000-0002-8390-8780" - family-names: "Gutowski" given-names: "Nicolas" orcid: "https://orcid.org/0000-0002-5765-9901" title: "MidiTok: A Python package for MIDI file tokenization" license: MIT date-released: 2021-11-07 url: "https://github.com/Natooz/MidiTok" repository-code: "https://github.com/Natooz/MidiTok"
GitHub Events
Total
Last Year
Dependencies
- actions/stale v5.1.1 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- codecov/codecov-action v3.1.0 composite
- actions/checkout v3 composite
- actions/setup-python v3 composite
- pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
- matplotlib *
- miditoolkit >=0.1.16
- numpy >=1.19,<1.24
- scipy *
- tokenizers >=0.13.2
- tqdm >=4.64.0
- matplotlib *
- miditoolkit >=0.1.16
- numpy >=1.19,<1.24
- scipy *
- tokenizers >=0.13.0
- tqdm *