Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -187,7 +187,7 @@ def load_midi(input_midi):
|
|
| 187 |
|
| 188 |
return melody_chords
|
| 189 |
|
| 190 |
-
def save_midi(tokens
|
| 191 |
"""Convert token sequence back to a MIDI score and write it using TMIDIX (without velocity).
|
| 192 |
The output MIDI file name incorporates a date-time stamp.
|
| 193 |
"""
|
|
@@ -248,7 +248,7 @@ def save_midi(tokens, batch_number=None):
|
|
| 248 |
# Generate a time stamp using the PDT timezone.
|
| 249 |
timestamp = datetime.datetime.now(PDT).strftime("%Y%m%d_%H%M%S")
|
| 250 |
|
| 251 |
-
fname = f"Orpheus-Music-Transformer-
|
| 252 |
|
| 253 |
TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(
|
| 254 |
song_f,
|
|
@@ -316,7 +316,7 @@ def generate_music_and_state(input_midi, num_prime_tokens, num_gen_tokens, num_m
|
|
| 316 |
output_batches = []
|
| 317 |
for i, tokens in enumerate(batched_gen_tokens):
|
| 318 |
preview_tokens = final_composition[-PREVIEW_LENGTH:]
|
| 319 |
-
midi_fname, midi_score = save_midi(preview_tokens + tokens
|
| 320 |
plot_kwargs = {'plot_title': f'Batch # {i}', 'return_plt': True}
|
| 321 |
|
| 322 |
if len(final_composition) > PREVIEW_LENGTH:
|
|
@@ -381,14 +381,6 @@ def remove_batch(batch_number, num_tokens, final_composition, generated_batches,
|
|
| 381 |
if block_lines:
|
| 382 |
block_lines.pop()
|
| 383 |
midi_fname, midi_score = save_midi(final_composition)
|
| 384 |
-
TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(
|
| 385 |
-
midi_score,
|
| 386 |
-
output_signature='Orpheus Music Transformer',
|
| 387 |
-
output_file_name=midi_fname,
|
| 388 |
-
track_name='Project Los Angeles',
|
| 389 |
-
list_of_MIDI_patches=[0]*16,
|
| 390 |
-
verbose=False
|
| 391 |
-
)
|
| 392 |
midi_plot = TMIDIX.plot_ms_SONG(
|
| 393 |
midi_score,
|
| 394 |
plot_title='Orpheus Music Transformer Composition',
|
|
|
|
| 187 |
|
| 188 |
return melody_chords
|
| 189 |
|
| 190 |
+
def save_midi(tokens):
|
| 191 |
"""Convert token sequence back to a MIDI score and write it using TMIDIX (without velocity).
|
| 192 |
The output MIDI file name incorporates a date-time stamp.
|
| 193 |
"""
|
|
|
|
| 248 |
# Generate a time stamp using the PDT timezone.
|
| 249 |
timestamp = datetime.datetime.now(PDT).strftime("%Y%m%d_%H%M%S")
|
| 250 |
|
| 251 |
+
fname = f"Orpheus-Music-Transformer-Composition"
|
| 252 |
|
| 253 |
TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(
|
| 254 |
song_f,
|
|
|
|
| 316 |
output_batches = []
|
| 317 |
for i, tokens in enumerate(batched_gen_tokens):
|
| 318 |
preview_tokens = final_composition[-PREVIEW_LENGTH:]
|
| 319 |
+
midi_fname, midi_score = save_midi(preview_tokens + tokens)
|
| 320 |
plot_kwargs = {'plot_title': f'Batch # {i}', 'return_plt': True}
|
| 321 |
|
| 322 |
if len(final_composition) > PREVIEW_LENGTH:
|
|
|
|
| 381 |
if block_lines:
|
| 382 |
block_lines.pop()
|
| 383 |
midi_fname, midi_score = save_midi(final_composition)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
midi_plot = TMIDIX.plot_ms_SONG(
|
| 385 |
midi_score,
|
| 386 |
plot_title='Orpheus Music Transformer Composition',
|