Spaces:
Running
on
Zero
Running
on
Zero
asigalov61
commited on
Commit
•
d7ab2ca
1
Parent(s):
4023dd5
Update app.py
Browse files
app.py
CHANGED
@@ -308,6 +308,7 @@ def generate_music(prime,
|
|
308 |
|
309 |
final_composition = []
|
310 |
generated_batches = []
|
|
|
311 |
|
312 |
#==================================================================================
|
313 |
|
@@ -426,15 +427,23 @@ def generate_callback_wrapper(input_midi,
|
|
426 |
#==================================================================================
|
427 |
|
428 |
def add_batch(batch_number):
|
|
|
|
|
|
|
|
|
429 |
|
430 |
final_composition.extend(generated_batches[batch_number])
|
431 |
|
432 |
# Save MIDI to a temporary file
|
433 |
midi_score = save_midi(final_composition)
|
|
|
434 |
|
435 |
# MIDI plot
|
436 |
-
midi_plot = TMIDIX.plot_ms_SONG(midi_score,
|
437 |
-
|
|
|
|
|
|
|
438 |
# File name
|
439 |
fname = 'Giant-Music-Transformer-Music-Composition'
|
440 |
|
@@ -455,12 +464,16 @@ def remove_batch(batch_number, num_tokens):
|
|
455 |
|
456 |
if len(final_composition) > num_tokens:
|
457 |
final_composition = final_composition[:-num_tokens]
|
|
|
458 |
|
459 |
# Save MIDI to a temporary file
|
460 |
midi_score = save_midi(final_composition)
|
461 |
|
462 |
# MIDI plot
|
463 |
-
midi_plot = TMIDIX.plot_ms_SONG(midi_score,
|
|
|
|
|
|
|
464 |
|
465 |
# File name
|
466 |
fname = 'Giant-Music-Transformer-Music-Composition'
|
@@ -477,8 +490,14 @@ def remove_batch(batch_number, num_tokens):
|
|
477 |
#==================================================================================
|
478 |
|
479 |
def reset():
|
|
|
480 |
global final_composition
|
|
|
|
|
|
|
481 |
final_composition = []
|
|
|
|
|
482 |
|
483 |
#==================================================================================
|
484 |
|
|
|
308 |
|
309 |
final_composition = []
|
310 |
generated_batches = []
|
311 |
+
block_lines = []
|
312 |
|
313 |
#==================================================================================
|
314 |
|
|
|
427 |
#==================================================================================
|
428 |
|
429 |
def add_batch(batch_number):
|
430 |
+
|
431 |
+
if not block_lines:
|
432 |
+
midi_score = save_midi(final_composition)
|
433 |
+
block_lines.append(midi_score[-1][1] / 1000)
|
434 |
|
435 |
final_composition.extend(generated_batches[batch_number])
|
436 |
|
437 |
# Save MIDI to a temporary file
|
438 |
midi_score = save_midi(final_composition)
|
439 |
+
block_lines.append(midi_score[-1][1] / 1000)
|
440 |
|
441 |
# MIDI plot
|
442 |
+
midi_plot = TMIDIX.plot_ms_SONG(midi_score,
|
443 |
+
plot_title='Giant Music Transformer Composition',
|
444 |
+
block_lines_times_list=block_lines[:-1],
|
445 |
+
return_plt=True)
|
446 |
+
|
447 |
# File name
|
448 |
fname = 'Giant-Music-Transformer-Music-Composition'
|
449 |
|
|
|
464 |
|
465 |
if len(final_composition) > num_tokens:
|
466 |
final_composition = final_composition[:-num_tokens]
|
467 |
+
block_lines.pop()
|
468 |
|
469 |
# Save MIDI to a temporary file
|
470 |
midi_score = save_midi(final_composition)
|
471 |
|
472 |
# MIDI plot
|
473 |
+
midi_plot = TMIDIX.plot_ms_SONG(midi_score,
|
474 |
+
plot_title='Giant Music Transformer Composition',
|
475 |
+
block_lines_times_list=block_lines[:-1],
|
476 |
+
return_plt=True)
|
477 |
|
478 |
# File name
|
479 |
fname = 'Giant-Music-Transformer-Music-Composition'
|
|
|
490 |
#==================================================================================
|
491 |
|
492 |
def reset():
|
493 |
+
|
494 |
global final_composition
|
495 |
+
global generated_batches
|
496 |
+
global block_lines
|
497 |
+
|
498 |
final_composition = []
|
499 |
+
generated_batches = []
|
500 |
+
block_lines = []
|
501 |
|
502 |
#==================================================================================
|
503 |
|