skytnt commited on
Commit
b56182d
1 Parent(s): 881b42e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -176,10 +176,14 @@ def run(model_name, tab, instruments, drum_kit, mid, midi_events, gen_events, te
176
  generator = generate(model, mid, max_len=max_len, temp=temp, top_p=top_p, top_k=top_k,
177
  disable_patch_change=disable_patch_change, disable_control_change=not allow_cc,
178
  disable_channels=disable_channels)
179
- for token_seq in generator:
180
- mid_seq.append(token_seq)
181
- draw_event(token_seq)
182
- yield mid_seq, get_img(), None, None
 
 
 
 
183
  mid = tokenizer.detokenize(mid_seq)
184
  with open(f"output.mid", 'wb') as f:
185
  f.write(MIDI.score2midi(mid))
 
176
  generator = generate(model, mid, max_len=max_len, temp=temp, top_p=top_p, top_k=top_k,
177
  disable_patch_change=disable_patch_change, disable_control_change=not allow_cc,
178
  disable_channels=disable_channels)
179
+ try:
180
+ for token_seq in generator:
181
+ mid_seq.append(token_seq)
182
+ draw_event(token_seq)
183
+ yield mid_seq, get_img(), None, None
184
+ except Exception as e:
185
+ print(e)
186
+
187
  mid = tokenizer.detokenize(mid_seq)
188
  with open(f"output.mid", 'wb') as f:
189
  f.write(MIDI.score2midi(mid))