Skip to content

Commit

Permalink
Merge pull request #2 from ms3744/ms3744-patch-tokenize-dataset
Browse files Browse the repository at this point in the history
Ms3744 patch tokenize dataset
  • Loading branch information
Natooz authored Aug 25, 2021
2 parents ff501a3 + de91d63 commit de360a9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions miditok/midi_tokenizer_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ def tokenize_midi_dataset(self, midi_paths: Union[List[str], List[Path], List[Pu
:param logging: logs a progress bar
"""
Path(out_dir).mkdir(parents=True, exist_ok=True)


# Making a directory of the parent folders for the JSON file
# parent_dir = PurePath(midi_paths[0]).parent[0]
# PurePath(out_dir, parent_dir).mkdir(parents=True, exist_ok=True)

for m, midi_path in enumerate(midi_paths):
if logging:
bar_len = 60
Expand All @@ -258,7 +262,8 @@ def tokenize_midi_dataset(self, midi_paths: Union[List[str], List[Path], List[Pu

# Converting the MIDI to tokens and saving them as json
tokens, track_info = self.midi_to_tokens(midi)
with open(PurePath(out_dir, midi_path).with_suffix(".json"), 'w') as outfile:
midi_name = PurePath(midi_path).stem
with open(PurePath(out_dir, midi_name).with_suffix(".json"), 'w') as outfile:
json.dump([tokens[0], track_info[0]], outfile)

self.save_params(out_dir) # Saves the parameters with which the MIDIs are converted
Expand Down

0 comments on commit de360a9

Please sign in to comment.