Update app.py
Browse files
app.py
CHANGED
@@ -310,13 +310,54 @@ if __name__ == "__main__":
|
|
310 |
|
311 |
soundfont = "SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2"
|
312 |
|
313 |
-
|
314 |
-
|
315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
print('=' * 70)
|
317 |
-
|
318 |
-
print('
|
319 |
-
classifier_labels = TMIDIX.Tegridy_Any_Pickle_File_Reader('
|
|
|
|
|
|
|
|
|
|
|
320 |
print('=' * 70)
|
321 |
|
322 |
app = gr.Blocks()
|
|
|
310 |
|
311 |
soundfont = "SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2"
|
312 |
|
313 |
+
#===============================================================================
|
314 |
+
# Helper functions
|
315 |
+
#===============================================================================
|
316 |
+
|
317 |
+
def str_strip_song(string):
|
318 |
+
if string is not None:
|
319 |
+
string = string.replace('-', ' ').replace('_', ' ').replace('=', ' ')
|
320 |
+
str1 = re.compile('[^a-zA-Z ]').sub('', string)
|
321 |
+
return re.sub(' +', ' ', str1).strip().title()
|
322 |
+
else:
|
323 |
+
return ''
|
324 |
+
|
325 |
+
def str_strip_artist(string):
|
326 |
+
if string is not None:
|
327 |
+
string = string.replace('-', ' ').replace('_', ' ').replace('=', ' ')
|
328 |
+
str1 = re.compile('[^0-9a-zA-Z ]').sub('', string)
|
329 |
+
return re.sub(' +', ' ', str1).strip().title()
|
330 |
+
else:
|
331 |
+
return ''
|
332 |
+
|
333 |
+
def song_artist_to_song_artist_tokens(file_name):
|
334 |
+
idx = classifier_labels.index(file_name)
|
335 |
+
|
336 |
+
tok1 = idx // 424
|
337 |
+
tok2 = idx % 424
|
338 |
+
|
339 |
+
return [tok1, tok2]
|
340 |
+
|
341 |
+
def song_artist_tokens_to_song_artist(file_name_tokens):
|
342 |
+
|
343 |
+
tok1 = file_name_tokens[0]
|
344 |
+
tok2 = file_name_tokens[1]
|
345 |
+
|
346 |
+
idx = (tok1 * 424) + tok2
|
347 |
+
|
348 |
+
return classifier_labels[idx]
|
349 |
+
|
350 |
+
#===============================================================================
|
351 |
+
|
352 |
print('=' * 70)
|
353 |
+
print('Loading Ultimate MIDI Classifier labels...')
|
354 |
+
print('=' * 70)
|
355 |
+
classifier_labels = TMIDIX.Tegridy_Any_Pickle_File_Reader('Ultimate-MIDI-Classifier/Data/Ultimate_MIDI_Classifier_Song_Artist_Labels')
|
356 |
+
print('=' * 70)
|
357 |
+
genre_labels = TMIDIX.Tegridy_Any_Pickle_File_Reader('Ultimate-MIDI-Classifier/Data/Ultimate_MIDI_Classifier_Music_Genre_Labels')
|
358 |
+
genre_labels_fnames = [f[0] for f in genre_labels]
|
359 |
+
print('=' * 70)
|
360 |
+
print('Done!')
|
361 |
print('=' * 70)
|
362 |
|
363 |
app = gr.Blocks()
|