Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions ariautils/tokenizer/absolute.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,14 @@ def _quantize_velocity(self, velocity: int) -> int:
return velocity_quantized

def _format(
self, prefix: list[Token], unformatted_seq: list[Token]
self,
prefix: list[Token],
unformatted_seq: list[Token],
add_dim_tok: bool = True,
) -> list[Token]:
# If unformatted_seq is longer than 150 tokens insert diminish tok
idx = -100 + random.randint(-10, 10)
if len(unformatted_seq) > 150:
if len(unformatted_seq) > 150 and add_dim_tok is True:
if (
unformatted_seq[idx][0] == "onset"
): # Don't want: note, <D>, onset, due
Expand Down Expand Up @@ -252,7 +255,10 @@ def truncate_by_time(
return tokenized_seq

def _tokenize_midi_dict(
self, midi_dict: MidiDict, remove_preceding_silence: bool = True
self,
midi_dict: MidiDict,
remove_preceding_silence: bool = True,
add_dim_tok: bool = True,
) -> list[Token]:
ticks_per_beat = midi_dict.ticks_per_beat
midi_dict.remove_instruments(self.config["ignore_instruments"])
Expand Down Expand Up @@ -367,6 +373,7 @@ def _tokenize_midi_dict(
return self._format(
prefix=prefix,
unformatted_seq=tokenized_seq,
add_dim_tok=add_dim_tok,
)

def tokenize(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_midi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""""Tests for MidiDict."""
"""Tests for MidiDict."""

import unittest
import tempfile
Expand Down
Loading