Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -188,7 +188,7 @@ def save_midi(tokens, batch_number=None):
|
|
| 188 |
list_of_MIDI_patches=patches,
|
| 189 |
verbose=False
|
| 190 |
)
|
| 191 |
-
return fname
|
| 192 |
|
| 193 |
# -----------------------------
|
| 194 |
# MUSIC GENERATION FUNCTION (Combined)
|
|
@@ -223,10 +223,10 @@ def generate_music_and_state(input_midi, num_prime_tokens, num_gen_tokens, num_m
|
|
| 223 |
# Load seed from MIDI if there is no existing composition.
|
| 224 |
if not final_composition and input_midi is not None:
|
| 225 |
final_composition = load_midi(input_midi)[:num_prime_tokens]
|
| 226 |
-
midi_fname = save_midi(final_composition)
|
| 227 |
# Use the last note's time as a marker.
|
| 228 |
midi_score = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(
|
| 229 |
-
|
| 230 |
output_signature='Godzilla Piano Transformer',
|
| 231 |
output_file_name=midi_fname,
|
| 232 |
track_name='Project Los Angeles',
|
|
@@ -245,7 +245,7 @@ def generate_music_and_state(input_midi, num_prime_tokens, num_gen_tokens, num_m
|
|
| 245 |
plot_kwargs = {'plot_title': f'Batch # {i}', 'return_plt': True}
|
| 246 |
if len(final_composition) > PREVIEW_LENGTH:
|
| 247 |
plot_kwargs['preview_length_in_notes'] = int(PREVIEW_LENGTH / 3)
|
| 248 |
-
|
| 249 |
preview_tokens + tokens,
|
| 250 |
output_signature='Godzilla Piano Transformer',
|
| 251 |
output_file_name=midi_fname,
|
|
@@ -253,7 +253,7 @@ def generate_music_and_state(input_midi, num_prime_tokens, num_gen_tokens, num_m
|
|
| 253 |
list_of_MIDI_patches=[0]*16,
|
| 254 |
verbose=False
|
| 255 |
)
|
| 256 |
-
midi_plot = TMIDIX.plot_ms_SONG(
|
| 257 |
midi_audio = midi_to_colab_audio(midi_fname + '.mid',
|
| 258 |
soundfont_path=SOUDFONT_PATH,
|
| 259 |
sample_rate=16000,
|
|
|
|
| 188 |
list_of_MIDI_patches=patches,
|
| 189 |
verbose=False
|
| 190 |
)
|
| 191 |
+
return fname, song_events
|
| 192 |
|
| 193 |
# -----------------------------
|
| 194 |
# MUSIC GENERATION FUNCTION (Combined)
|
|
|
|
| 223 |
# Load seed from MIDI if there is no existing composition.
|
| 224 |
if not final_composition and input_midi is not None:
|
| 225 |
final_composition = load_midi(input_midi)[:num_prime_tokens]
|
| 226 |
+
midi_fname, song_events = save_midi(final_composition)
|
| 227 |
# Use the last note's time as a marker.
|
| 228 |
midi_score = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(
|
| 229 |
+
song_events,
|
| 230 |
output_signature='Godzilla Piano Transformer',
|
| 231 |
output_file_name=midi_fname,
|
| 232 |
track_name='Project Los Angeles',
|
|
|
|
| 245 |
plot_kwargs = {'plot_title': f'Batch # {i}', 'return_plt': True}
|
| 246 |
if len(final_composition) > PREVIEW_LENGTH:
|
| 247 |
plot_kwargs['preview_length_in_notes'] = int(PREVIEW_LENGTH / 3)
|
| 248 |
+
TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(
|
| 249 |
preview_tokens + tokens,
|
| 250 |
output_signature='Godzilla Piano Transformer',
|
| 251 |
output_file_name=midi_fname,
|
|
|
|
| 253 |
list_of_MIDI_patches=[0]*16,
|
| 254 |
verbose=False
|
| 255 |
)
|
| 256 |
+
midi_plot = TMIDIX.plot_ms_SONG(preview_tokens + tokens, **plot_kwargs)
|
| 257 |
midi_audio = midi_to_colab_audio(midi_fname + '.mid',
|
| 258 |
soundfont_path=SOUDFONT_PATH,
|
| 259 |
sample_rate=16000,
|