asigalov61 commited on
Commit
fd58682
1 Parent(s): d0f533f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -8
app.py CHANGED
@@ -28,7 +28,7 @@ in_space = os.getenv("SYSTEM") == "spaces"
28
 
29
  #==========================================================================================================
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)))
@@ -96,6 +96,8 @@ def render_midi(input_midi, render_options):
96
  volume_scale=10,
97
  output_for_gradio=True
98
  )
 
 
99
 
100
  print('Sample INTs', escore[:5])
101
  print('=' * 70)
@@ -123,12 +125,26 @@ def render_midi(input_midi, render_options):
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')
129
-
130
- yield AUX_DATA[search_match_index][0], AUX_DATA[search_match_index][1], AUX_DATA[search_match_index][2], AUX_DATA[search_match_index][3], fn+'.mid', (16000, audio), plt
131
 
 
 
 
 
132
  #==========================================================================================================
133
 
134
  if __name__ == "__main__":
@@ -177,12 +193,9 @@ if __name__ == "__main__":
177
  output_midi_summary = gr.Textbox(label="Output MIDI summary")
178
  output_audio = gr.Audio(label="Output MIDI audio", format="wav", elem_id="midi_audio")
179
  output_plot = gr.Plot(label="Output MIDI score plot")
180
- output_midi_lyric = gr.Textbox(label="Output Karaoke MIDI lyric")
181
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
182
-
183
- render_options = [render_as_is, extract_melody, transform]
184
 
185
- run_event = submit.click(render_midi, [input_midi, render_options],
186
- [output_midi_md5, output_midi_title, output_midi_lyric, output_midi_summary, output_midi, output_audio, output_plot])
187
 
188
  app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
 
28
 
29
  #==========================================================================================================
30
 
31
+ def render_midi(input_midi, render_as_is, extract_melody, transform):
32
 
33
  print('=' * 70)
34
  print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
 
96
  volume_scale=10,
97
  output_for_gradio=True
98
  )
99
+
100
+ new_md5_hash = hashlib.md5(open(new_fn,'rb').read()).hexdigest()
101
 
102
  print('Sample INTs', escore[:5])
103
  print('=' * 70)
 
125
  plt.xlabel("Time in ms")
126
  plt.ylabel("MIDI Pitch")
127
 
128
+ #========================================================
129
+
130
+
131
+ output_midi_md5 = str(new_md5_hash)
132
+ output_midi_title = str(fn1)
133
+ output_midi_summary = str(meta_data)
134
+ output_midi = str(new_fn)
135
+ output_audio = (16000, audio)
136
+ output_plot = plt
137
+
138
+ #========================================================
139
+
140
  print('Req end time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
141
  print('-' * 70)
142
  print('Req execution time:', (time.time() - start_time), 'sec')
 
 
143
 
144
+ #========================================================
145
+
146
+ yield output_midi_md5, output_midi_title, output_midi_summary, output_midi, output_audio, output_plot
147
+
148
  #==========================================================================================================
149
 
150
  if __name__ == "__main__":
 
193
  output_midi_summary = gr.Textbox(label="Output MIDI summary")
194
  output_audio = gr.Audio(label="Output MIDI audio", format="wav", elem_id="midi_audio")
195
  output_plot = gr.Plot(label="Output MIDI score plot")
 
196
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
 
 
197
 
198
+ run_event = submit.click(render_midi, [input_midi, render_as_is, extract_melody, transform],
199
+ [output_midi_md5, output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
200
 
201
  app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)