asigalov61
commited on
Commit
•
e2a8b2b
1
Parent(s):
aba820e
Update app.py
Browse files
app.py
CHANGED
@@ -49,9 +49,10 @@ def render_midi(input_midi,
|
|
49 |
soundfont_bank,
|
50 |
render_sample_rate,
|
51 |
custom_render_patch,
|
|
|
|
|
52 |
render_transpose_value,
|
53 |
render_transpose_to_C4,
|
54 |
-
render_align,
|
55 |
render_output_as_solo_piano,
|
56 |
render_remove_drums
|
57 |
):
|
@@ -80,9 +81,10 @@ def render_midi(input_midi,
|
|
80 |
print('Soudnfont bank', soundfont_bank)
|
81 |
print('Audio render sample rate', render_sample_rate)
|
82 |
print('Custom MIDI render patch', custom_render_patch)
|
|
|
|
|
83 |
print('Transpose value:', render_transpose_value)
|
84 |
print('Transpose to C4', render_transpose_to_C4)
|
85 |
-
print('Align to bars:', render_align)
|
86 |
print('Output as Solo Piano', render_output_as_solo_piano)
|
87 |
print('Remove drums:', render_remove_drums)
|
88 |
print('=' * 70)
|
@@ -109,7 +111,7 @@ def render_midi(input_midi,
|
|
109 |
print('=' * 70)
|
110 |
print('Processing...Please wait...')
|
111 |
|
112 |
-
if render_type == 'Render as-is' or render_type == "
|
113 |
output_score = copy.deepcopy(escore)
|
114 |
|
115 |
elif render_type == "Custom render" or not render_type:
|
@@ -169,7 +171,10 @@ def render_midi(input_midi,
|
|
169 |
output_score = TMIDIX.recalculate_score_timings(output_score)
|
170 |
output_score = TMIDIX.align_escore_notes_to_bars(output_score, split_durations=True)
|
171 |
|
172 |
-
if render_type == "
|
|
|
|
|
|
|
173 |
zscore = TMIDIX.recalculate_score_timings(output_score)
|
174 |
c_escore_notes = TMIDIX.compress_patches_in_escore_notes_chords(zscore)
|
175 |
cmatrix = TMIDIX.escore_notes_to_image_matrix(c_escore_notes, filter_out_zero_rows=True, filter_out_duplicate_rows=True)
|
@@ -186,7 +191,7 @@ def render_midi(input_midi,
|
|
186 |
if render_remove_drums:
|
187 |
output_score = TMIDIX.strip_drums_from_escore_notes(output_score)
|
188 |
|
189 |
-
if render_type == "Solo Piano
|
190 |
sp_escore_notes = TMIDIX.solo_piano_escore_notes(output_score, keep_drums=False)
|
191 |
zscore = TMIDIX.recalculate_score_timings(sp_escore_notes)
|
192 |
bmatrix = TMIDIX.escore_notes_to_binary_matrix(zscore)
|
@@ -348,8 +353,7 @@ if __name__ == "__main__":
|
|
348 |
"Flip",
|
349 |
"Reverse",
|
350 |
"Repair",
|
351 |
-
"
|
352 |
-
"Solo Piano Summary"
|
353 |
],
|
354 |
label="Render type",
|
355 |
value="Render as-is"
|
@@ -358,9 +362,15 @@ if __name__ == "__main__":
|
|
358 |
gr.Markdown("## Select custom render options")
|
359 |
|
360 |
custom_render_patch = gr.Slider(-1, 127, value=-1, label="Custom render MIDI patch")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
|
362 |
-
render_transpose_value = gr.Slider(-12, 12, value=0, step=1, label="Transpose value")
|
363 |
-
render_transpose_to_C4 = gr.Checkbox(label="Transpose to C4", value=False)
|
364 |
render_align = gr.Radio(["Do not align",
|
365 |
"Start Times",
|
366 |
"Start Times and Durations",
|
@@ -368,7 +378,11 @@ if __name__ == "__main__":
|
|
368 |
],
|
369 |
label="Align output to bars",
|
370 |
value="Do not align"
|
371 |
-
)
|
|
|
|
|
|
|
|
|
372 |
|
373 |
render_output_as_solo_piano = gr.Checkbox(label="Output as Solo Piano", value=False)
|
374 |
render_remove_drums = gr.Checkbox(label="Remove drums", value=False)
|
@@ -389,11 +403,12 @@ if __name__ == "__main__":
|
|
389 |
soundfont_bank,
|
390 |
render_sample_rate,
|
391 |
custom_render_patch,
|
|
|
|
|
392 |
render_transpose_value,
|
393 |
render_transpose_to_C4,
|
394 |
-
render_align,
|
395 |
render_output_as_solo_piano,
|
396 |
-
render_remove_drums
|
397 |
],
|
398 |
[output_midi_md5,
|
399 |
output_midi_title,
|
|
|
49 |
soundfont_bank,
|
50 |
render_sample_rate,
|
51 |
custom_render_patch,
|
52 |
+
render_align,
|
53 |
+
render_summary_type,
|
54 |
render_transpose_value,
|
55 |
render_transpose_to_C4,
|
|
|
56 |
render_output_as_solo_piano,
|
57 |
render_remove_drums
|
58 |
):
|
|
|
81 |
print('Soudnfont bank', soundfont_bank)
|
82 |
print('Audio render sample rate', render_sample_rate)
|
83 |
print('Custom MIDI render patch', custom_render_patch)
|
84 |
+
print('Align to bars:', render_align)
|
85 |
+
print('Summary type:', render_summary_type)
|
86 |
print('Transpose value:', render_transpose_value)
|
87 |
print('Transpose to C4', render_transpose_to_C4)
|
|
|
88 |
print('Output as Solo Piano', render_output_as_solo_piano)
|
89 |
print('Remove drums:', render_remove_drums)
|
90 |
print('=' * 70)
|
|
|
111 |
print('=' * 70)
|
112 |
print('Processing...Please wait...')
|
113 |
|
114 |
+
if render_type == 'Render as-is' or render_type == "Summarize":
|
115 |
output_score = copy.deepcopy(escore)
|
116 |
|
117 |
elif render_type == "Custom render" or not render_type:
|
|
|
171 |
output_score = TMIDIX.recalculate_score_timings(output_score)
|
172 |
output_score = TMIDIX.align_escore_notes_to_bars(output_score, split_durations=True)
|
173 |
|
174 |
+
if render_type == "Summarize" and render_summary_type == 'Principal Phrase':
|
175 |
+
pass
|
176 |
+
|
177 |
+
if render_type == "Summarize" and render_summary_type == 'Multi-Instrumental':
|
178 |
zscore = TMIDIX.recalculate_score_timings(output_score)
|
179 |
c_escore_notes = TMIDIX.compress_patches_in_escore_notes_chords(zscore)
|
180 |
cmatrix = TMIDIX.escore_notes_to_image_matrix(c_escore_notes, filter_out_zero_rows=True, filter_out_duplicate_rows=True)
|
|
|
191 |
if render_remove_drums:
|
192 |
output_score = TMIDIX.strip_drums_from_escore_notes(output_score)
|
193 |
|
194 |
+
if render_type == "Summarize" and render_summary_type == 'Solo Piano':
|
195 |
sp_escore_notes = TMIDIX.solo_piano_escore_notes(output_score, keep_drums=False)
|
196 |
zscore = TMIDIX.recalculate_score_timings(sp_escore_notes)
|
197 |
bmatrix = TMIDIX.escore_notes_to_binary_matrix(zscore)
|
|
|
353 |
"Flip",
|
354 |
"Reverse",
|
355 |
"Repair",
|
356 |
+
"Summarize",
|
|
|
357 |
],
|
358 |
label="Render type",
|
359 |
value="Render as-is"
|
|
|
362 |
gr.Markdown("## Select custom render options")
|
363 |
|
364 |
custom_render_patch = gr.Slider(-1, 127, value=-1, label="Custom render MIDI patch")
|
365 |
+
|
366 |
+
render_summary_type = gr.Radio(["Multi-Instrumental",
|
367 |
+
"Solo Piano",
|
368 |
+
"Principal Phrase",
|
369 |
+
],
|
370 |
+
label="Summary type",
|
371 |
+
value="Multi-Instrumental"
|
372 |
+
)
|
373 |
|
|
|
|
|
374 |
render_align = gr.Radio(["Do not align",
|
375 |
"Start Times",
|
376 |
"Start Times and Durations",
|
|
|
378 |
],
|
379 |
label="Align output to bars",
|
380 |
value="Do not align"
|
381 |
+
)
|
382 |
+
|
383 |
+
render_transpose_value = gr.Slider(-12, 12, value=0, step=1, label="Transpose value")
|
384 |
+
render_transpose_to_C4 = gr.Checkbox(label="Transpose to C4", value=False)
|
385 |
+
|
386 |
|
387 |
render_output_as_solo_piano = gr.Checkbox(label="Output as Solo Piano", value=False)
|
388 |
render_remove_drums = gr.Checkbox(label="Remove drums", value=False)
|
|
|
403 |
soundfont_bank,
|
404 |
render_sample_rate,
|
405 |
custom_render_patch,
|
406 |
+
render_align,
|
407 |
+
render_summary_type,
|
408 |
render_transpose_value,
|
409 |
render_transpose_to_C4,
|
|
|
410 |
render_output_as_solo_piano,
|
411 |
+
render_remove_drums
|
412 |
],
|
413 |
[output_midi_md5,
|
414 |
output_midi_title,
|