asigalov61
commited on
Commit
•
2f9b3e2
1
Parent(s):
d34b744
Update app.py
Browse files
app.py
CHANGED
@@ -17,9 +17,7 @@ from midi_to_colab_audio import midi_to_colab_audio
|
|
17 |
import TMIDIX
|
18 |
|
19 |
import matplotlib.pyplot as plt
|
20 |
-
|
21 |
-
in_space = os.getenv("SYSTEM") == "spaces"
|
22 |
-
|
23 |
# =================================================================================================
|
24 |
|
25 |
def pitches_counts(melody_score):
|
@@ -120,7 +118,14 @@ def mix_chord(chord, tones_chord, mel_patch, mel_pitch, next_note_dtime):
|
|
120 |
|
121 |
# =================================================================================================
|
122 |
|
123 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
print('=' * 70)
|
125 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
126 |
start_time = reqtime.time()
|
@@ -135,6 +140,8 @@ def MixMelody(input_midi, input_find_best_match, input_adjust_melody_notes_durat
|
|
135 |
print('Find best matches', input_find_best_match)
|
136 |
print('Adjust melody notes durations:', input_adjust_melody_notes_durations)
|
137 |
print('Adjust accompaniment notes durations:', input_adjust_accompaniment_notes_durations)
|
|
|
|
|
138 |
print('-' * 70)
|
139 |
|
140 |
#===============================================================================
|
@@ -238,6 +245,13 @@ def MixMelody(input_midi, input_find_best_match, input_adjust_melody_notes_durat
|
|
238 |
print('Done!')
|
239 |
print('=' * 70)
|
240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
#===============================================================================
|
242 |
print('Rendering results...')
|
243 |
|
@@ -341,14 +355,14 @@ if __name__ == "__main__":
|
|
341 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
342 |
|
343 |
|
344 |
-
run_event = run_btn.click(
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
|
353 |
gr.Examples(
|
354 |
[["Abracadabra-Sample-Melody.mid", True, True, True, False],
|
@@ -362,7 +376,7 @@ if __name__ == "__main__":
|
|
362 |
input_remove_drums
|
363 |
],
|
364 |
[output_midi_title, output_midi_summary, output_midi, output_audio, output_plot],
|
365 |
-
|
366 |
cache_examples=True,
|
367 |
)
|
368 |
|
|
|
17 |
import TMIDIX
|
18 |
|
19 |
import matplotlib.pyplot as plt
|
20 |
+
|
|
|
|
|
21 |
# =================================================================================================
|
22 |
|
23 |
def pitches_counts(melody_score):
|
|
|
118 |
|
119 |
# =================================================================================================
|
120 |
|
121 |
+
def Mix_Melody(input_midi,
|
122 |
+
input_find_best_match,
|
123 |
+
input_adjust_melody_notes_durations,
|
124 |
+
input_adjust_accompaniment_notes_durations,
|
125 |
+
input_output_as_solo_piano,
|
126 |
+
input_remove_drums
|
127 |
+
):
|
128 |
+
|
129 |
print('=' * 70)
|
130 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
131 |
start_time = reqtime.time()
|
|
|
140 |
print('Find best matches', input_find_best_match)
|
141 |
print('Adjust melody notes durations:', input_adjust_melody_notes_durations)
|
142 |
print('Adjust accompaniment notes durations:', input_adjust_accompaniment_notes_durations)
|
143 |
+
print('Output as Solo Piano:', input_output_as_solo_piano)
|
144 |
+
print('Remove drums:', input_remove_drums)
|
145 |
print('-' * 70)
|
146 |
|
147 |
#===============================================================================
|
|
|
245 |
print('Done!')
|
246 |
print('=' * 70)
|
247 |
|
248 |
+
#===============================================================================
|
249 |
+
|
250 |
+
if
|
251 |
+
|
252 |
+
|
253 |
+
|
254 |
+
|
255 |
#===============================================================================
|
256 |
print('Rendering results...')
|
257 |
|
|
|
355 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
356 |
|
357 |
|
358 |
+
run_event = run_btn.click(Mix_Melody, [input_midi,
|
359 |
+
input_find_best_match,
|
360 |
+
input_adjust_melody_notes_durations,
|
361 |
+
input_adjust_accompaniment_notes_durations,
|
362 |
+
input_output_as_solo_piano,
|
363 |
+
input_remove_drums
|
364 |
+
],
|
365 |
+
[output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
|
366 |
|
367 |
gr.Examples(
|
368 |
[["Abracadabra-Sample-Melody.mid", True, True, True, False],
|
|
|
376 |
input_remove_drums
|
377 |
],
|
378 |
[output_midi_title, output_midi_summary, output_midi, output_audio, output_plot],
|
379 |
+
Mix_Melody,
|
380 |
cache_examples=True,
|
381 |
)
|
382 |
|