Spaces:
Running
Running
asigalov61
commited on
Commit
•
eb9414e
1
Parent(s):
52b276e
Update app.py
Browse files
app.py
CHANGED
@@ -18,10 +18,7 @@ import TMIDIX
|
|
18 |
|
19 |
# =================================================================================================
|
20 |
|
21 |
-
def Mix_Chords(
|
22 |
-
input_adjust_melody_notes_durations,
|
23 |
-
input_adjust_accompaniment_notes_durations,
|
24 |
-
input_output_as_solo_piano,
|
25 |
input_remove_drums,
|
26 |
input_output_tempo,
|
27 |
input_transform,
|
@@ -38,9 +35,6 @@ def Mix_Chords(input_find_best_match,
|
|
38 |
print('-' * 70)
|
39 |
print('Requested settings:')
|
40 |
print('-' * 70)
|
41 |
-
print('Find best matches', input_find_best_match)
|
42 |
-
print('Adjust melody notes durations:', input_adjust_melody_notes_durations)
|
43 |
-
print('Adjust accompaniment notes durations:', input_adjust_accompaniment_notes_durations)
|
44 |
print('Output as Solo Piano:', input_output_as_solo_piano)
|
45 |
print('Remove drums:', input_remove_drums)
|
46 |
print('Output tempo:', input_output_tempo)
|
@@ -191,6 +185,45 @@ if __name__ == "__main__":
|
|
191 |
soundfont = "SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2"
|
192 |
|
193 |
all_chords_chunks = TMIDIX.Tegridy_Any_Pickle_File_Reader('Los_Angeles_Chords_Songs_MIDI_Dataset_79898_128_256')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
print('=' * 70)
|
195 |
|
196 |
app = gr.Blocks()
|
@@ -207,37 +240,30 @@ if __name__ == "__main__":
|
|
207 |
|
208 |
gr.Markdown("## Select mixing options")
|
209 |
|
210 |
-
input_find_best_match = gr.Checkbox(label="Find best match", value=False)
|
211 |
-
input_adjust_melody_notes_durations = gr.Checkbox(label="Adjust melody notes durations", value=False)
|
212 |
-
input_adjust_accompaniment_notes_durations = gr.Checkbox(label="Adjust accompaniment notes durations", value=False)
|
213 |
input_output_as_solo_piano = gr.Checkbox(label="Output as Solo Piano", value=False)
|
214 |
input_remove_drums = gr.Checkbox(label="Remove drums from output", value=False)
|
215 |
-
input_output_tempo = gr.Radio(["
|
216 |
input_transform = gr.Radio(["As-is", "Flip Melody", "Reverse Melody", "Flip Mix", "Reverse Mix"], value="As-is", label="Transform")
|
217 |
input_transpose_value = gr.Slider(-12, 12, value=0, step=1, label="Transpose value")
|
218 |
input_transpose_to_C4 = gr.Checkbox(label="Transpose to C4", value=False)
|
219 |
|
220 |
-
run_btn = gr.Button("
|
221 |
|
222 |
gr.Markdown("## Output results")
|
223 |
|
224 |
output_midi_title = gr.Textbox(label="Output MIDI title")
|
225 |
-
output_midi_summary = gr.Textbox(label="Output MIDI summary")
|
226 |
output_audio = gr.Audio(label="Output MIDI audio", format="mp3", elem_id="midi_audio")
|
227 |
output_plot = gr.Plot(label="Output MIDI score plot")
|
228 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
229 |
|
230 |
|
231 |
-
run_event = run_btn.click(Mix_Chords, [
|
232 |
-
input_adjust_melody_notes_durations,
|
233 |
-
input_adjust_accompaniment_notes_durations,
|
234 |
-
input_output_as_solo_piano,
|
235 |
input_remove_drums,
|
236 |
input_output_tempo,
|
237 |
input_transform,
|
238 |
input_transpose_to_C4,
|
239 |
input_transpose_value
|
240 |
],
|
241 |
-
[output_midi_title,
|
242 |
|
243 |
app.queue().launch()
|
|
|
18 |
|
19 |
# =================================================================================================
|
20 |
|
21 |
+
def Mix_Chords(input_output_as_solo_piano,
|
|
|
|
|
|
|
22 |
input_remove_drums,
|
23 |
input_output_tempo,
|
24 |
input_transform,
|
|
|
35 |
print('-' * 70)
|
36 |
print('Requested settings:')
|
37 |
print('-' * 70)
|
|
|
|
|
|
|
38 |
print('Output as Solo Piano:', input_output_as_solo_piano)
|
39 |
print('Remove drums:', input_remove_drums)
|
40 |
print('Output tempo:', input_output_tempo)
|
|
|
185 |
soundfont = "SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2"
|
186 |
|
187 |
all_chords_chunks = TMIDIX.Tegridy_Any_Pickle_File_Reader('Los_Angeles_Chords_Songs_MIDI_Dataset_79898_128_256')
|
188 |
+
|
189 |
+
print('=' * 70)
|
190 |
+
print('Prepping loaded data...')
|
191 |
+
|
192 |
+
#=====================================================================
|
193 |
+
|
194 |
+
chords_drums_counts = []
|
195 |
+
|
196 |
+
for a in all_chords_chunks:
|
197 |
+
score = a[1]
|
198 |
+
ccount = 0
|
199 |
+
dcount = 0
|
200 |
+
for s in score:
|
201 |
+
if any(a[2] < 80 for a in s):
|
202 |
+
ccount += 1
|
203 |
+
if all(a[2] == 128 for a in s):
|
204 |
+
dcount += 1
|
205 |
+
|
206 |
+
chords_drums_counts.append([ccount, dcount])
|
207 |
+
|
208 |
+
#=====================================================================
|
209 |
+
|
210 |
+
all_chords_indexes = []
|
211 |
+
|
212 |
+
for a in all_chords_chunks:
|
213 |
+
|
214 |
+
score = a[1]
|
215 |
+
|
216 |
+
chords_indexes = []
|
217 |
+
|
218 |
+
for i, s in enumerate(score):
|
219 |
+
if any(a[2] < 80 for a in s):
|
220 |
+
chords_indexes.append(i)
|
221 |
+
|
222 |
+
all_chords_indexes.append(chords_indexes)
|
223 |
+
|
224 |
+
#=====================================================================
|
225 |
+
|
226 |
+
print('Done!')
|
227 |
print('=' * 70)
|
228 |
|
229 |
app = gr.Blocks()
|
|
|
240 |
|
241 |
gr.Markdown("## Select mixing options")
|
242 |
|
|
|
|
|
|
|
243 |
input_output_as_solo_piano = gr.Checkbox(label="Output as Solo Piano", value=False)
|
244 |
input_remove_drums = gr.Checkbox(label="Remove drums from output", value=False)
|
245 |
+
input_output_tempo = gr.Radio(["Source MIDI", "Target MIDI", "MIDI Mix"], value="Mix", label="Output tempo")
|
246 |
input_transform = gr.Radio(["As-is", "Flip Melody", "Reverse Melody", "Flip Mix", "Reverse Mix"], value="As-is", label="Transform")
|
247 |
input_transpose_value = gr.Slider(-12, 12, value=0, step=1, label="Transpose value")
|
248 |
input_transpose_to_C4 = gr.Checkbox(label="Transpose to C4", value=False)
|
249 |
|
250 |
+
run_btn = gr.Button("Mix Chords", variant="primary")
|
251 |
|
252 |
gr.Markdown("## Output results")
|
253 |
|
254 |
output_midi_title = gr.Textbox(label="Output MIDI title")
|
|
|
255 |
output_audio = gr.Audio(label="Output MIDI audio", format="mp3", elem_id="midi_audio")
|
256 |
output_plot = gr.Plot(label="Output MIDI score plot")
|
257 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
258 |
|
259 |
|
260 |
+
run_event = run_btn.click(Mix_Chords, [input_output_as_solo_piano,
|
|
|
|
|
|
|
261 |
input_remove_drums,
|
262 |
input_output_tempo,
|
263 |
input_transform,
|
264 |
input_transpose_to_C4,
|
265 |
input_transpose_value
|
266 |
],
|
267 |
+
[output_midi_title, output_midi, output_audio, output_plot])
|
268 |
|
269 |
app.queue().launch()
|