Skip to content

Commit c6bd0b9

Browse files
author
Cannon Lock
committed
Temp
1 parent 47303d9 commit c6bd0b9

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

DeepLearning.py

+5-24
Original file line numberDiff line numberDiff line change
@@ -91,31 +91,12 @@ def get_dataset(includeDuration = False, byGenre = False, regenerate = False):
9191

9292
return dataset
9393

94-
def build_vocab(includeDuration = False):
95-
""" Get all the notes and chords from the midi files in the ./midi_songs directory """
96-
notes = []
94+
def build_vocab(notes, includeDuration = False):
95+
vocab = set()
96+
for i in songs:
97+
vocab.update(i)
9798

98-
for j in GENRES:
99-
for file in glob.glob("../TrainingData/" + j + "/*.mid"):
100-
midi = converter.parse(file)
101-
102-
print("Parsing %s" % file)
103-
104-
notes_to_parse = None
105-
106-
try: # file has instrument parts
107-
s2 = instrument.partitionByInstrument(midi)
108-
notes_to_parse = s2.parts[0].recurse()
109-
except: # file has notes in a flat structure
110-
notes_to_parse = midi.flat.notes
111-
112-
for el in notes_to_parse:
113-
if isinstance(el, note.Note) or isinstance(el, chord.Chord) or isinstance(el, note.Rest):
114-
notes.append(get_element_str(el, includeDuration))
115-
116-
np.save("notes_duration:" + str(includeDuration), notes)
117-
118-
return notes
99+
return vocab
119100

120101
def standardize_songs(songs):
121102

0 commit comments

Comments
 (0)