INNER CODE UNIT · Python
sentence
jisungk/deepjazz · generator.py:53
sentence = corpus[start_index: start_index + max_len] # seed
running_length = 0.0
while running_length <= 4.1: # arbitrary, from avg in input file
# transform sentence (previous sequence) to matrix
x = np.zeros((1, max_len, len(values)))
for t, val in enumerate(sentence):
if (not val in val_indices): print(val)
x[0, t, val_indices[val]] = 1.
next_val = __predict(model, x, indices_val, diversity)
# fix first note: must not have < > and not be a rest
if (running_length < 0.00001):
tries = 0
while (next_val.split(',')[0] == 'R' or
len(next_val.split(',')) != 2):
# give up after 1000 tries; random from input's first notes
if tries >= max_tries: