asigalov61 commited on
Commit
86dfaf8
1 Parent(s): 03ab473

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -14
app.py CHANGED
@@ -114,14 +114,6 @@ def find_midi(title, artist):
114
 
115
  song_f.append(['note', time, dur, channel, pitch, vel, patch ])
116
 
117
- patches = [0 if x==-1 else x for x in patches]
118
-
119
- detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(song_f,
120
- output_signature = 'Giant Music Transformer',
121
- output_file_name = '/content/Giant-Music-Transformer-Music-Composition_'+str(i),
122
- track_name='Project Los Angeles',
123
- list_of_MIDI_patches=patches
124
- )
125
 
126
 
127
  x = []
@@ -133,7 +125,7 @@ def find_midi(title, artist):
133
  'gray', 'white', 'gold', 'silver',
134
  'lightgreen', 'indigo', 'maroon', 'turquoise']
135
 
136
- for s in [m for m in mid_seq if m[0] == 'note']:
137
  x.append(s[1])
138
  y.append(s[4])
139
  c.append(colors[s[3]])
@@ -148,8 +140,8 @@ def find_midi(title, artist):
148
  plt.ylabel("MIDI Pitch")
149
 
150
  with open(f"MIDI-Match-Sample.mid", 'wb') as f:
151
- f.write(MIDI.score2midi([mid_seq_ticks, mid_seq]))
152
- audio = synthesis(MIDI.score2opus([mid_seq_ticks, mid_seq]), soundfont_path)
153
  yield txt_mdata, "MIDI-Match-Sample.mid", (44100, audio), plt
154
 
155
  #==========================================================================================================
@@ -184,9 +176,10 @@ if __name__ == "__main__":
184
  )
185
 
186
  gr.Markdown("# Upload MIDI")
187
-
188
- artist = gr.Textbox()
189
  title = gr.Textbox()
 
 
190
 
191
  gr.Markdown("# Match results")
192
 
@@ -195,7 +188,7 @@ if __name__ == "__main__":
195
  output_midi = gr.File(label="Output MIDI match sample MIDI", file_types=[".mid"])
196
  output_midi_seq = gr.Textbox(label="Output MIDI match metadata")
197
 
198
- run_event = input_midi.upload(match_midi, [input_midi, maximum_match_ratio],
199
  [output_midi_seq, output_midi, output_audio, output_plot])
200
 
201
  app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
 
114
 
115
  song_f.append(['note', time, dur, channel, pitch, vel, patch ])
116
 
 
 
 
 
 
 
 
 
117
 
118
 
119
  x = []
 
125
  'gray', 'white', 'gold', 'silver',
126
  'lightgreen', 'indigo', 'maroon', 'turquoise']
127
 
128
+ for s in [m for m in song_f if m[0] == 'note']:
129
  x.append(s[1])
130
  y.append(s[4])
131
  c.append(colors[s[3]])
 
140
  plt.ylabel("MIDI Pitch")
141
 
142
  with open(f"MIDI-Match-Sample.mid", 'wb') as f:
143
+ f.write(MIDI.score2midi([1000, song_f]))
144
+ audio = synthesis(MIDI.score2opus([1000, song_f]), soundfont_path)
145
  yield txt_mdata, "MIDI-Match-Sample.mid", (44100, audio), plt
146
 
147
  #==========================================================================================================
 
176
  )
177
 
178
  gr.Markdown("# Upload MIDI")
179
+
 
180
  title = gr.Textbox()
181
+ artist = gr.Textbox()
182
+ submit = gr.Button()
183
 
184
  gr.Markdown("# Match results")
185
 
 
188
  output_midi = gr.File(label="Output MIDI match sample MIDI", file_types=[".mid"])
189
  output_midi_seq = gr.Textbox(label="Output MIDI match metadata")
190
 
191
+ run_event = submit.click(find_midi, [title, artist],
192
  [output_midi_seq, output_midi, output_audio, output_plot])
193
 
194
  app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)