asigalov61 commited on
Commit
a04859d
1 Parent(s): 7303461

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -26
app.py CHANGED
@@ -120,7 +120,7 @@ def find_midi(search_string, search_options):
120
  print('-' * 70)
121
  print('Req execution time:', (time.time() - start_time), 'sec')
122
 
123
- yield AUX_DATA[search_match_index][0], str(search_match_ratio), AUX_DATA[search_match_index][1], AUX_DATA[search_match_index][2], AUX_DATA[search_match_index][3], fn+'.mid', (16000, audio), plt
124
 
125
  #==========================================================================================================
126
 
@@ -135,48 +135,39 @@ if __name__ == "__main__":
135
  parser = argparse.ArgumentParser()
136
  parser.add_argument("--share", action="store_true", default=False, help="share gradio app")
137
  parser.add_argument("--port", type=int, default=7860, help="gradio server port")
138
- parser.add_argument("--max-gen", type=int, default=1024, help="max")
139
 
140
  opt = parser.parse_args()
141
 
142
- soundfont_path = "SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2"
143
- meta_data_path = "English_Karaoke_Files_Titles_Lyrics_Summaries_Scores_Final.pickle"
144
 
145
- print('Loading meta-data...')
146
- with open(meta_data_path, 'rb') as f:
147
- AUX_DATA = pickle.load(f)
148
- print('Done!')
149
-
150
  app = gr.Blocks()
151
  with app:
152
- gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>Karaoke MIDI Search</h1>")
153
- gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>Search and explore 5865 select Karaoke MIDI titles</h1>")
154
 
155
- gr.Markdown("![Visitors](https://api.visitorbadge.io/api/visitors?path=asigalov61.Karaoke-MIDI-Search&style=flat)\n\n"
156
  "Los Angeles MIDI Dataset Demo\n\n"
157
  "Please see [Los Angeles MIDI Dataset](https://github.com/asigalov61/Los-Angeles-MIDI-Dataset) for more information and features\n\n"
158
  "[Open In Colab]"
159
  "(https://colab.research.google.com/github/asigalov61/Los-Angeles-MIDI-Dataset/blob/main/Los_Angeles_MIDI_Dataset_Search_and_Explore.ipynb)"
160
  " for all features\n\n"
161
- "Presented lyrics titles, transcriptions, and summaries were auto-generated with [Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2) so please keep it in mind"
162
- )
163
-
164
- search_string = gr.Textbox(label="Enter search prompt here", value="So close, no matter how far\nCouldn't be much more from the heart\nForever trusting who we are\nAnd nothing else matters")
165
- search_options = gr.CheckboxGroup(["Titles", "Lyrics", "Summaries"], value="Lyrics", label="Search within")
166
  submit = gr.Button()
167
 
168
- gr.Markdown("# Search results")
169
 
170
- output_midi_search_match_ratio = gr.Textbox(label="Output Karaoke MIDI search match ratio")
171
- output_midi_md5 = gr.Textbox(label="Output Karaoke MIDI md5 hash")
172
- output_midi_title = gr.Textbox(label="Output Karaoke MIDI title")
173
- output_midi_summary = gr.Textbox(label="Output Karaoke MIDI summary")
174
- output_audio = gr.Audio(label="Output Karaoke MIDI audio", format="wav", elem_id="midi_audio")
175
- output_plot = gr.Plot(label="Output Karaoke MIDI score plot")
176
  output_midi_lyric = gr.Textbox(label="Output Karaoke MIDI lyric")
177
- output_midi = gr.File(label="Output Karaoke MIDI original file", file_types=[".mid"])
178
 
179
  run_event = submit.click(find_midi, [search_string, search_options],
180
- [output_midi_md5, output_midi_search_match_ratio, output_midi_title, output_midi_lyric, output_midi_summary, output_midi, output_audio, output_plot])
181
 
182
  app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
 
120
  print('-' * 70)
121
  print('Req execution time:', (time.time() - start_time), 'sec')
122
 
123
+ 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
124
 
125
  #==========================================================================================================
126
 
 
135
  parser = argparse.ArgumentParser()
136
  parser.add_argument("--share", action="store_true", default=False, help="share gradio app")
137
  parser.add_argument("--port", type=int, default=7860, help="gradio server port")
 
138
 
139
  opt = parser.parse_args()
140
 
141
+ soundfonts = ["SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2", "Nice-Strings-PlusOrchestra-v1.6.sf2", "KBH-Real-Choir-V2.5.sf2"]
 
142
 
 
 
 
 
 
143
  app = gr.Blocks()
144
  with app:
145
+ gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>Advanced MIDI Renderer</h1>")
146
+ gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>Transform and render any MIDI</h1>")
147
 
148
+ gr.Markdown("![Visitors](https://api.visitorbadge.io/api/visitors?path=asigalov61.Advanced-MIDI-Renderer&style=flat)\n\n"
149
  "Los Angeles MIDI Dataset Demo\n\n"
150
  "Please see [Los Angeles MIDI Dataset](https://github.com/asigalov61/Los-Angeles-MIDI-Dataset) for more information and features\n\n"
151
  "[Open In Colab]"
152
  "(https://colab.research.google.com/github/asigalov61/Los-Angeles-MIDI-Dataset/blob/main/Los_Angeles_MIDI_Dataset_Search_and_Explore.ipynb)"
153
  " for all features\n\n"
154
+ )
155
+ gr.Markdown("# Upload your MIDI")
156
+ input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"], type="binary")
157
+ render_options = gr.Checkbox(["Render as-is", "Extract melody", "Transform"], value="Lyrics", label="MIDI render options")
 
158
  submit = gr.Button()
159
 
160
+ gr.Markdown("# Render results")
161
 
162
+ output_midi_md5 = gr.Textbox(label="Output MIDI md5 hash")
163
+ output_midi_title = gr.Textbox(label="Output MIDI title")
164
+ output_midi_summary = gr.Textbox(label="Output MIDI summary")
165
+ output_audio = gr.Audio(label="Output MIDI audio", format="wav", elem_id="midi_audio")
166
+ output_plot = gr.Plot(label="Output MIDI score plot")
 
167
  output_midi_lyric = gr.Textbox(label="Output Karaoke MIDI lyric")
168
+ output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
169
 
170
  run_event = submit.click(find_midi, [search_string, search_options],
171
+ [output_midi_md5, output_midi_title, output_midi_lyric, output_midi_summary, output_midi, output_audio, output_plot])
172
 
173
  app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)