asigalov61 commited on
Commit
0e6d052
1 Parent(s): 64e4f3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -17
app.py CHANGED
@@ -52,12 +52,7 @@ def find_midi(input_search_string):
52
  closest_index = np.argmax(similarities)
53
  closest_index_match_ratio = max(similarities[0].tolist())
54
 
55
- best_corpus_match = all_MIDI_files_names[closest_index]
56
-
57
- top_ten_matches = ''
58
-
59
- for t in top_ten_matches_idxs:
60
- top_ten_matches += str(all_MIDI_files_names[t][0]).title() + '\n'
61
 
62
  print('Done!')
63
  print('=' * 70)
@@ -69,9 +64,9 @@ def find_midi(input_search_string):
69
  print('Done!')
70
  print('=' * 70)
71
 
72
- song_artist = best_corpus_match[0]
73
- song_artist_title = str(song_artist).title()
74
- zlib_file_name = best_corpus_match[1]
75
 
76
  print('Fetching MIDI score...')
77
 
@@ -86,13 +81,14 @@ def find_midi(input_search_string):
86
 
87
  fnames = [f[0] for f in scores_data]
88
 
89
- fnameidx = fnames.index(song_artist)
90
-
91
- MIDI_score_data = scores_data[fnameidx][1]
 
92
 
93
  print('Rendering results...')
94
  print('=' * 70)
95
- print('MIDi Title:', song_artist_title)
96
  print('Sample INTs', MIDI_score_data[:12])
97
  print('=' * 70)
98
 
@@ -163,12 +159,12 @@ def find_midi(input_search_string):
163
 
164
  detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(output_score,
165
  output_signature = 'LAKH MIDI Dataset Search',
166
- output_file_name = song_artist_title,
167
  track_name='Project Los Angeles',
168
  list_of_MIDI_patches=patches
169
  )
170
 
171
- new_fn = song_artist_title + '.mid'
172
 
173
  audio = midi_to_colab_audio(new_fn,
174
  soundfont_path=soundfont,
@@ -182,8 +178,8 @@ def find_midi(input_search_string):
182
 
183
  #========================================================
184
 
185
- output_midi_title = str(song_artist_title)
186
- output_midi_summary = str(top_ten_matches)
187
  output_midi = str(new_fn)
188
  output_audio = (16000, audio)
189
 
 
52
  closest_index = np.argmax(similarities)
53
  closest_index_match_ratio = max(similarities[0].tolist())
54
 
55
+ best_corpus_match = mc_dataset['train'][closest_index]
 
 
 
 
 
56
 
57
  print('Done!')
58
  print('=' * 70)
 
64
  print('Done!')
65
  print('=' * 70)
66
 
67
+ LAKH_hash = best_corpus_match['location'].split('/')[-1].split('.mid')[0]
68
+ LAKH_caption = str(best_corpus_match['caption'])
69
+ zlib_file_name = all_MIDI_files_names[MIDI_files_names.index(LAKH_hash)][1]
70
 
71
  print('Fetching MIDI score...')
72
 
 
81
 
82
  fnames = [f[0] for f in scores_data]
83
 
84
+ fnameidx = fnames.index(LAKH_hash)
85
+
86
+ MIDI_score_metadata = scores_data[fnameidx][1]
87
+ MIDI_score_data = scores_data[fnameidx][2]
88
 
89
  print('Rendering results...')
90
  print('=' * 70)
91
+ print('MIDi Title:', LAKH_hash)
92
  print('Sample INTs', MIDI_score_data[:12])
93
  print('=' * 70)
94
 
 
159
 
160
  detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(output_score,
161
  output_signature = 'LAKH MIDI Dataset Search',
162
+ output_file_name = LAKH_hash,
163
  track_name='Project Los Angeles',
164
  list_of_MIDI_patches=patches
165
  )
166
 
167
+ new_fn = LAKH_hash + '.mid'
168
 
169
  audio = midi_to_colab_audio(new_fn,
170
  soundfont_path=soundfont,
 
178
 
179
  #========================================================
180
 
181
+ output_midi_title = str(LAKH_hash)
182
+ output_midi_summary = str(MIDI_score_metadata)
183
  output_midi = str(new_fn)
184
  output_audio = (16000, audio)
185