Update app.py
Browse files
app.py
CHANGED
|
@@ -30,7 +30,7 @@ in_space = os.getenv("SYSTEM") == "spaces"
|
|
| 30 |
|
| 31 |
def render_midi(input_midi, render_options):
|
| 32 |
|
| 33 |
-
print('
|
| 34 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
| 35 |
start_time = time.time()
|
| 36 |
print('=' * 70)
|
|
@@ -78,12 +78,33 @@ def render_midi(input_midi, render_options):
|
|
| 78 |
print('=' * 70)
|
| 79 |
print('Input MIDI metadata:', meta_data)
|
| 80 |
print('=' * 70)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
new_fn = fn1+'.mid'
|
| 83 |
|
| 84 |
patches = [0] * 16
|
| 85 |
|
| 86 |
-
detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(
|
| 87 |
output_signature = 'Advanced MIDI Renderer',
|
| 88 |
output_file_name = fn1,
|
| 89 |
track_name='Project Los Angeles',
|
|
@@ -99,12 +120,11 @@ def render_midi(input_midi, render_options):
|
|
| 99 |
|
| 100 |
new_md5_hash = hashlib.md5(open(new_fn,'rb').read()).hexdigest()
|
| 101 |
|
| 102 |
-
print('
|
| 103 |
print('=' * 70)
|
| 104 |
|
| 105 |
#========================================================
|
| 106 |
|
| 107 |
-
|
| 108 |
output_midi_md5 = str(new_md5_hash)
|
| 109 |
output_midi_title = str(fn1)
|
| 110 |
output_midi_summary = str(meta_data)
|
|
@@ -112,12 +132,19 @@ def render_midi(input_midi, render_options):
|
|
| 112 |
output_audio = (16000, audio)
|
| 113 |
output_plot = TMIDIX.plot_ms_SONG(escore, plot_title=output_midi)
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
#========================================================
|
| 116 |
|
| 117 |
print('Req end time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
| 118 |
print('-' * 70)
|
| 119 |
print('Req execution time:', (time.time() - start_time), 'sec')
|
| 120 |
-
|
| 121 |
#========================================================
|
| 122 |
|
| 123 |
yield output_midi_md5, output_midi_title, output_midi_summary, output_midi, output_audio, output_plot
|
|
@@ -158,7 +185,7 @@ if __name__ == "__main__":
|
|
| 158 |
|
| 159 |
gr.Markdown("## Select desired render options")
|
| 160 |
|
| 161 |
-
render_options = gr.CheckboxGroup(["Render as-is", "Extract melody", "Transform"])
|
| 162 |
|
| 163 |
submit = gr.Button()
|
| 164 |
|
|
|
|
| 30 |
|
| 31 |
def render_midi(input_midi, render_options):
|
| 32 |
|
| 33 |
+
print('*' * 70)
|
| 34 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
| 35 |
start_time = time.time()
|
| 36 |
print('=' * 70)
|
|
|
|
| 78 |
print('=' * 70)
|
| 79 |
print('Input MIDI metadata:', meta_data)
|
| 80 |
print('=' * 70)
|
| 81 |
+
print('Processing...Please wait...')
|
| 82 |
+
|
| 83 |
+
if render_options == ["Render as-is"] or not render_options:
|
| 84 |
+
output_score = escore
|
| 85 |
|
| 86 |
+
print('Done processing!')
|
| 87 |
+
print('=' * 70)
|
| 88 |
+
|
| 89 |
+
print('Recalculating timings...')
|
| 90 |
+
print('=' * 70)
|
| 91 |
+
|
| 92 |
+
for e in output_score:
|
| 93 |
+
e[1] = e[1] * 16
|
| 94 |
+
e[2] = e[2] * 16
|
| 95 |
+
|
| 96 |
+
print('Done recalculating timings!')
|
| 97 |
+
print('=' * 70)
|
| 98 |
+
|
| 99 |
+
print('Sample output events', output_score[:5])
|
| 100 |
+
print('=' * 70)
|
| 101 |
+
print('Final processing...')
|
| 102 |
+
|
| 103 |
new_fn = fn1+'.mid'
|
| 104 |
|
| 105 |
patches = [0] * 16
|
| 106 |
|
| 107 |
+
detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(output_score,
|
| 108 |
output_signature = 'Advanced MIDI Renderer',
|
| 109 |
output_file_name = fn1,
|
| 110 |
track_name='Project Los Angeles',
|
|
|
|
| 120 |
|
| 121 |
new_md5_hash = hashlib.md5(open(new_fn,'rb').read()).hexdigest()
|
| 122 |
|
| 123 |
+
print('Done!')
|
| 124 |
print('=' * 70)
|
| 125 |
|
| 126 |
#========================================================
|
| 127 |
|
|
|
|
| 128 |
output_midi_md5 = str(new_md5_hash)
|
| 129 |
output_midi_title = str(fn1)
|
| 130 |
output_midi_summary = str(meta_data)
|
|
|
|
| 132 |
output_audio = (16000, audio)
|
| 133 |
output_plot = TMIDIX.plot_ms_SONG(escore, plot_title=output_midi)
|
| 134 |
|
| 135 |
+
print('Output MIDI file name:', output_midi)
|
| 136 |
+
print('Output MIDI title:', output_midi_title)
|
| 137 |
+
print('Output MIDI hash:', output_midi_md5)
|
| 138 |
+
print('Output MIDI summary:', output_midi_summary)
|
| 139 |
+
print('=' * 70)
|
| 140 |
+
|
| 141 |
+
|
| 142 |
#========================================================
|
| 143 |
|
| 144 |
print('Req end time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
| 145 |
print('-' * 70)
|
| 146 |
print('Req execution time:', (time.time() - start_time), 'sec')
|
| 147 |
+
print('*' * 70)
|
| 148 |
#========================================================
|
| 149 |
|
| 150 |
yield output_midi_md5, output_midi_title, output_midi_summary, output_midi, output_audio, output_plot
|
|
|
|
| 185 |
|
| 186 |
gr.Markdown("## Select desired render options")
|
| 187 |
|
| 188 |
+
render_options = gr.CheckboxGroup(["Render as-is", "Extract melody", "Transform"], value="Render as-is"])
|
| 189 |
|
| 190 |
submit = gr.Button()
|
| 191 |
|