Update app.py
Browse files
app.py
CHANGED
|
@@ -37,7 +37,7 @@ def render_midi(input_midi, render_options):
|
|
| 37 |
print('Loading MIDI...')
|
| 38 |
|
| 39 |
fn = os.path.basename(input_midi)
|
| 40 |
-
fn1 = fn.split('.')[
|
| 41 |
|
| 42 |
fdata = open(input_midi, 'rb').read()
|
| 43 |
|
|
@@ -79,8 +79,25 @@ def render_midi(input_midi, render_options):
|
|
| 79 |
print('Input MIDI metadata:', meta_data)
|
| 80 |
print('=' * 70)
|
| 81 |
|
|
|
|
| 82 |
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
print('=' * 70)
|
| 85 |
|
| 86 |
x = []
|
|
@@ -106,16 +123,6 @@ def render_midi(input_midi, render_options):
|
|
| 106 |
plt.xlabel("Time in ms")
|
| 107 |
plt.ylabel("MIDI Pitch")
|
| 108 |
|
| 109 |
-
with open(fn+'.mid', 'wb') as f:
|
| 110 |
-
f.write(TMIDIX.score2midi(raw_score))
|
| 111 |
-
|
| 112 |
-
audio = midi_to_colab_audio(fn+'.mid',
|
| 113 |
-
soundfont_path=soundfont[0],
|
| 114 |
-
sample_rate=16000, # 44100
|
| 115 |
-
volume_scale=10,
|
| 116 |
-
output_for_gradio=True
|
| 117 |
-
)
|
| 118 |
-
|
| 119 |
print('Req end time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
| 120 |
print('-' * 70)
|
| 121 |
print('Req execution time:', (time.time() - start_time), 'sec')
|
|
@@ -167,7 +174,7 @@ if __name__ == "__main__":
|
|
| 167 |
output_midi_lyric = gr.Textbox(label="Output Karaoke MIDI lyric")
|
| 168 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
| 169 |
|
| 170 |
-
run_event = submit.click(
|
| 171 |
-
|
| 172 |
|
| 173 |
app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
|
|
|
|
| 37 |
print('Loading MIDI...')
|
| 38 |
|
| 39 |
fn = os.path.basename(input_midi)
|
| 40 |
+
fn1 = fn.split('.')[0]
|
| 41 |
|
| 42 |
fdata = open(input_midi, 'rb').read()
|
| 43 |
|
|
|
|
| 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(escore,
|
| 87 |
+
output_signature = 'Advanced MIDI Renderer',
|
| 88 |
+
output_file_name = new_fn,
|
| 89 |
+
track_name='Project Los Angeles',
|
| 90 |
+
list_of_MIDI_patches=patches
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
audio = midi_to_colab_audio(new_fn,
|
| 94 |
+
soundfont_path=soundfonts[0],
|
| 95 |
+
sample_rate=16000, # 44100
|
| 96 |
+
volume_scale=10,
|
| 97 |
+
output_for_gradio=True
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
print('Sample INTs', escore[:5])
|
| 101 |
print('=' * 70)
|
| 102 |
|
| 103 |
x = []
|
|
|
|
| 123 |
plt.xlabel("Time in ms")
|
| 124 |
plt.ylabel("MIDI Pitch")
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
print('Req end time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
| 127 |
print('-' * 70)
|
| 128 |
print('Req execution time:', (time.time() - start_time), 'sec')
|
|
|
|
| 174 |
output_midi_lyric = gr.Textbox(label="Output Karaoke MIDI lyric")
|
| 175 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
| 176 |
|
| 177 |
+
run_event = submit.click(render_midi, [input_midi, render_options],
|
| 178 |
+
[output_midi_md5, output_midi_title, output_midi_lyric, output_midi_summary, output_midi, output_audio, output_plot])
|
| 179 |
|
| 180 |
app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
|