Spaces:
Running
on
Zero
Running
on
Zero
asigalov61
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -55,6 +55,8 @@ SOUDFONT_PATH = 'SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2'
|
|
55 |
|
56 |
NUM_OUT_BATCHES = 8
|
57 |
|
|
|
|
|
58 |
#==================================================================================
|
59 |
|
60 |
print('=' * 70)
|
@@ -339,21 +341,26 @@ def generate_callback(input_midi,
|
|
339 |
|
340 |
tokens = batched_gen_tokens[i]
|
341 |
|
|
|
|
|
|
|
342 |
# Save MIDI to a temporary file
|
343 |
-
midi_score = save_midi(tokens, i)
|
344 |
|
345 |
# MIDI plot
|
346 |
-
midi_plot = TMIDIX.plot_ms_SONG(midi_score, plot_title='Batch # ' + str(i), return_plt=True)
|
347 |
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
|
|
|
|
|
|
357 |
|
358 |
outputs.append(((16000, midi_audio), midi_plot, tokens))
|
359 |
|
|
|
55 |
|
56 |
NUM_OUT_BATCHES = 8
|
57 |
|
58 |
+
PREVIEW_LENGTH = 120
|
59 |
+
|
60 |
#==================================================================================
|
61 |
|
62 |
print('=' * 70)
|
|
|
341 |
|
342 |
tokens = batched_gen_tokens[i]
|
343 |
|
344 |
+
# Preview
|
345 |
+
tokens_preview = final_composition[-PREVIEW_LENGTH:]
|
346 |
+
|
347 |
# Save MIDI to a temporary file
|
348 |
+
midi_score = save_midi(tokens_preview + tokens, i)
|
349 |
|
350 |
# MIDI plot
|
|
|
351 |
|
352 |
+
if len(final_composition) > PREVIEW_LENGTH:
|
353 |
+
midi_plot = TMIDIX.plot_ms_SONG(midi_score,
|
354 |
+
plot_title='Batch # ' + str(i),
|
355 |
+
preview_length_in_notes=int(PREVIEW_LENGTH / 3),
|
356 |
+
return_plt=True
|
357 |
+
)
|
358 |
+
|
359 |
+
else:
|
360 |
+
midi_plot = TMIDIX.plot_ms_SONG(midi_score,
|
361 |
+
plot_title='Batch # ' + str(i),
|
362 |
+
return_plt=True
|
363 |
+
)
|
364 |
|
365 |
outputs.append(((16000, midi_audio), midi_plot, tokens))
|
366 |
|