asigalov61
commited on
Commit
•
660b28d
1
Parent(s):
986e4d1
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,9 @@ import argparse
|
|
2 |
import glob
|
3 |
import os.path
|
4 |
|
|
|
|
|
|
|
5 |
import gradio as gr
|
6 |
|
7 |
import pickle
|
@@ -25,16 +28,19 @@ in_space = os.getenv("SYSTEM") == "spaces"
|
|
25 |
#==========================================================================================================
|
26 |
|
27 |
def find_midi(search_string, search_options):
|
28 |
-
|
29 |
print('=' * 70)
|
30 |
-
print('
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
32 |
print('=' * 70)
|
33 |
print('Preparing to search...')
|
34 |
|
35 |
#==================================================
|
36 |
|
37 |
-
|
38 |
random.shuffle(AUX_DATA)
|
39 |
|
40 |
search_data = []
|
@@ -59,6 +65,7 @@ def find_midi(search_string, search_options):
|
|
59 |
|
60 |
print('Done!')
|
61 |
print('=' * 70)
|
|
|
62 |
print('Selected file/title:', AUX_DATA[search_match_index][:2])
|
63 |
print('=' * 70)
|
64 |
|
@@ -93,19 +100,25 @@ def find_midi(search_string, search_options):
|
|
93 |
ax=plt.axes(title=title)
|
94 |
ax.set_facecolor('black')
|
95 |
|
96 |
-
plt.scatter(x,y, s=
|
97 |
plt.xlabel("Time in MIDI ticks")
|
98 |
plt.ylabel("MIDI Pitch")
|
99 |
|
100 |
with open(fn+'.mid', 'wb') as f:
|
101 |
f.write(TMIDIX.score2midi(raw_score))
|
|
|
102 |
audio = midi_to_colab_audio(fn+'.mid',
|
103 |
soundfont_path=soundfont_path,
|
104 |
sample_rate=16000, # 44100
|
105 |
volume_scale=10,
|
106 |
output_for_gradio=True
|
107 |
)
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
#==========================================================================================================
|
111 |
|
@@ -138,12 +151,13 @@ if __name__ == "__main__":
|
|
138 |
" for all features"
|
139 |
)
|
140 |
|
141 |
-
search_string = gr.Textbox(label="Enter search prompt here", value="
|
142 |
-
search_options = gr.CheckboxGroup(["Titles", "Lyrics", "Summaries"], value="Lyrics", label="Search within"
|
143 |
submit = gr.Button()
|
144 |
|
145 |
gr.Markdown("# Search results")
|
146 |
-
|
|
|
147 |
output_midi_md5 = gr.Textbox(label="Output Karaoke MIDI md5 hash")
|
148 |
output_midi_title = gr.Textbox(label="Output Karaoke MIDI title")
|
149 |
output_audio = gr.Audio(label="Output Karaoke MIDI audio", format="wav", elem_id="midi_audio")
|
@@ -153,6 +167,6 @@ if __name__ == "__main__":
|
|
153 |
output_midi = gr.File(label="Output Karaoke MIDI original file", file_types=[".mid"])
|
154 |
|
155 |
run_event = submit.click(find_midi, [search_string, search_options],
|
156 |
-
[output_midi_md5, output_midi_title, output_midi_lyric, output_midi_summary, output_midi, output_audio, output_plot])
|
157 |
|
158 |
app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
|
|
|
2 |
import glob
|
3 |
import os.path
|
4 |
|
5 |
+
import time
|
6 |
+
import datetime
|
7 |
+
|
8 |
import gradio as gr
|
9 |
|
10 |
import pickle
|
|
|
28 |
#==========================================================================================================
|
29 |
|
30 |
def find_midi(search_string, search_options):
|
|
|
31 |
print('=' * 70)
|
32 |
+
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
33 |
+
start_time = time.time()
|
34 |
+
|
35 |
+
print('=' * 70)
|
36 |
+
print('Search string:', search_string)
|
37 |
+
print('Search options:', search_options)
|
38 |
+
|
39 |
print('=' * 70)
|
40 |
print('Preparing to search...')
|
41 |
|
42 |
#==================================================
|
43 |
|
|
|
44 |
random.shuffle(AUX_DATA)
|
45 |
|
46 |
search_data = []
|
|
|
65 |
|
66 |
print('Done!')
|
67 |
print('=' * 70)
|
68 |
+
print('Search match ratio:', search_match_ratio)
|
69 |
print('Selected file/title:', AUX_DATA[search_match_index][:2])
|
70 |
print('=' * 70)
|
71 |
|
|
|
100 |
ax=plt.axes(title=title)
|
101 |
ax.set_facecolor('black')
|
102 |
|
103 |
+
plt.scatter(x,y, s=10, c=c)
|
104 |
plt.xlabel("Time in MIDI ticks")
|
105 |
plt.ylabel("MIDI Pitch")
|
106 |
|
107 |
with open(fn+'.mid', 'wb') as f:
|
108 |
f.write(TMIDIX.score2midi(raw_score))
|
109 |
+
|
110 |
audio = midi_to_colab_audio(fn+'.mid',
|
111 |
soundfont_path=soundfont_path,
|
112 |
sample_rate=16000, # 44100
|
113 |
volume_scale=10,
|
114 |
output_for_gradio=True
|
115 |
)
|
116 |
+
|
117 |
+
print('Req end time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
118 |
+
print('-' * 70)
|
119 |
+
print('Req execution time:', (time.time() - start_time), 'sec')
|
120 |
+
|
121 |
+
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
|
122 |
|
123 |
#==========================================================================================================
|
124 |
|
|
|
151 |
" for all features"
|
152 |
)
|
153 |
|
154 |
+
search_string = gr.Textbox(label="Enter search prompt here", value="Nothing Else Matters")
|
155 |
+
search_options = gr.CheckboxGroup(["Titles", "Lyrics", "Summaries"], value="Lyrics", label="Search within")
|
156 |
submit = gr.Button()
|
157 |
|
158 |
gr.Markdown("# Search results")
|
159 |
+
|
160 |
+
output_midi_search_match_ratio = gr.Textbox(label="Output Karaoke MIDI search match ratio")
|
161 |
output_midi_md5 = gr.Textbox(label="Output Karaoke MIDI md5 hash")
|
162 |
output_midi_title = gr.Textbox(label="Output Karaoke MIDI title")
|
163 |
output_audio = gr.Audio(label="Output Karaoke MIDI audio", format="wav", elem_id="midi_audio")
|
|
|
167 |
output_midi = gr.File(label="Output Karaoke MIDI original file", file_types=[".mid"])
|
168 |
|
169 |
run_event = submit.click(find_midi, [search_string, search_options],
|
170 |
+
[output_midi_md5, output_midi_search_match_ratio, output_midi_title, output_midi_lyric, output_midi_summary, output_midi, output_audio, output_plot])
|
171 |
|
172 |
app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
|