asigalov61 commited on
Commit
64e309b
1 Parent(s): 003cd1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -24,28 +24,32 @@ in_space = os.getenv("SYSTEM") == "spaces"
24
 
25
  #==========================================================================================================
26
 
27
- def find_midi(title, artist):
28
 
29
  print('=' * 70)
30
- print('Loading MIDI file...')
31
 
32
  #==================================================
33
 
34
- print('Searching titles...Please wait...')
35
  random.shuffle(AUX_DATA)
36
 
37
- titles_index = []
38
 
39
  for A in AUX_DATA:
40
- titles_index.append(A[0])
 
 
 
 
 
 
 
 
41
 
42
- search_string = ''
43
 
44
- if title != '' and artist != '':
45
- search_string = title + ' --- ' + artist
46
 
47
- else:
48
- search_string = title + artist
49
 
50
  search_match = process.extract(query=search_string, choices=titles_index, limit=1)
51
  search_index = titles_index.index(search_match[0][0])
@@ -215,7 +219,7 @@ if __name__ == "__main__":
215
  output_plot = gr.Plot(label="Output MIDI search sample plot")
216
  output_midi = gr.File(label="Output MIDI search sample MIDI", file_types=[".mid"])
217
 
218
- run_event = submit.click(find_midi, [title, artist],
219
  [output_midi_seq, output_midi, output_audio, output_plot])
220
 
221
  app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
 
24
 
25
  #==========================================================================================================
26
 
27
+ def find_midi(search_string, search_options):
28
 
29
  print('=' * 70)
30
+ print('Preparing to search...')
31
 
32
  #==================================================
33
 
34
+
35
  random.shuffle(AUX_DATA)
36
 
37
+ search_data = []
38
 
39
  for A in AUX_DATA:
40
+ data = []
41
+ if 'Titles' in search_options:
42
+ data.append(A[1])
43
+ if 'Lyrics' in search_options:
44
+ data.append(A[2])
45
+ if 'Summaries' in search_options:
46
+ data.append(A[3])
47
+
48
+ search_data.append(data)
49
 
50
+ print('Searching titles...Please wait...')
51
 
 
 
52
 
 
 
53
 
54
  search_match = process.extract(query=search_string, choices=titles_index, limit=1)
55
  search_index = titles_index.index(search_match[0][0])
 
219
  output_plot = gr.Plot(label="Output MIDI search sample plot")
220
  output_midi = gr.File(label="Output MIDI search sample MIDI", file_types=[".mid"])
221
 
222
+ run_event = submit.click(find_midi, [search_string, search_options],
223
  [output_midi_seq, output_midi, output_audio, output_plot])
224
 
225
  app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)