If you encounter errors, check that:
The MIDI file exists and is not corrupted.
music21 is properly installed (pip show music21).
The file path in data_fn is correct.
To visualize the MIDI file’s notation, replace show("text") with show() (requires MuseScore).
To play the MIDI file, use midi_data.show('midi') (requires a MIDI player).