When I was trying to run this line of code:
X, Y, n_values, indices_values, chords = load_music_utils('data/original_metheny.mid')
I got:
/var/folders/xw/b17c_b31565_0dq3hp8373kr0000gn/T/ipykernel_24786/325991792.py in <module>
----> 1 X, Y, n_values, indices_values, chords = load_music_utils('data/original_metheny.mid')
2 print('number of training examples:', X.shape[0])
3 print('Tx (length of sequence):', X.shape[1])
4 print('total # of unique values:', n_values)
5 print('shape of X:', X.shape)
~/projects/ml_notes/dl_course/exercises/05_Sequence_Models/03/data_utils.py in load_music_utils(file)
18
19 def load_music_utils(file):
---> 20 chords, abstract_grammars = get_musical_data(file)
21 corpus, tones, tones_indices, indices_tones = get_corpus_data(abstract_grammars)
22 N_tones = len(set(corpus))
~/projects/ml_notes/dl_course/exercises/05_Sequence_Models/03/preprocess.py in get_musical_data(data_fn)
133 def get_musical_data(data_fn):
134
--> 135 measures, chords = __parse_midi(data_fn)
136 abstract_grammars = __get_abstract_grammars(measures, chords)
137
~/projects/ml_notes/dl_course/exercises/05_Sequence_Models/03/preprocess.py in __parse_midi(data_fn)
27 # Get melody part, compress into single voice.
28 melody_stream = midi_data[5] # For Metheny piece, Melody is Part #5.
---> 29 melody1, melody2 = melody_stream.getElementsByClass(stream.Voice)
30 for j in melody2:
31 melody1.insert(j.offset, j)
ValueError: not enough values to unpack (expected 2, got 0)
Didn’t make any change to the code. I found melody_stream
only contains a list of Measures
and no Voice
is in the stream.
Any idea why this happens?