Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -236,7 +236,7 @@ def Generate_Accompaniment(input_midi,
|
|
236 |
print('Source melody patch:', melody_patch)
|
237 |
print('Use nth melody note:', use_nth_note)
|
238 |
print('Model temperature:', model_temperature)
|
239 |
-
print('Model top k'
|
240 |
|
241 |
print('=' * 70)
|
242 |
|
@@ -245,6 +245,7 @@ def Generate_Accompaniment(input_midi,
|
|
245 |
print('Prepping melody...')
|
246 |
|
247 |
if input_midi:
|
|
|
248 |
score, score_list = load_midi(input_midi.name, melody_patch, use_nth_note)
|
249 |
|
250 |
else:
|
@@ -351,12 +352,14 @@ def Generate_Accompaniment(input_midi,
|
|
351 |
|
352 |
#========================================================
|
353 |
|
|
|
354 |
output_midi = str(new_fn)
|
355 |
output_audio = (16000, audio)
|
356 |
|
357 |
output_plot = TMIDIX.plot_ms_SONG(song_f, plot_title=output_midi, return_plt=True)
|
358 |
|
359 |
print('Output MIDI file name:', output_midi)
|
|
|
360 |
print('=' * 70)
|
361 |
|
362 |
#========================================================
|
@@ -366,7 +369,7 @@ def Generate_Accompaniment(input_midi,
|
|
366 |
print('-' * 70)
|
367 |
print('Req execution time:', (reqtime.time() - start_time), 'sec')
|
368 |
|
369 |
-
return output_audio, output_plot, output_midi
|
370 |
|
371 |
#==================================================================================
|
372 |
|
@@ -398,9 +401,15 @@ with gr.Blocks() as demo:
|
|
398 |
|
399 |
gr.Markdown("## Upload source melody MIDI or enter a search query for a sample melody below")
|
400 |
|
401 |
-
input_midi = gr.File(label="Input MIDI",
|
|
|
|
|
|
|
402 |
|
403 |
-
input_melody = gr.Textbox(value="Hotel California",
|
|
|
|
|
|
|
404 |
|
405 |
gr.Markdown("## Generation options")
|
406 |
|
@@ -412,7 +421,8 @@ with gr.Blocks() as demo:
|
|
412 |
generate_btn = gr.Button("Generate", variant="primary")
|
413 |
|
414 |
gr.Markdown("## Generation results")
|
415 |
-
|
|
|
416 |
output_audio = gr.Audio(label="MIDI audio", format="wav", elem_id="midi_audio")
|
417 |
output_plot = gr.Plot(label="MIDI score plot")
|
418 |
output_midi = gr.File(label="MIDI file", file_types=[".mid"])
|
@@ -425,7 +435,8 @@ with gr.Blocks() as demo:
|
|
425 |
model_temperature,
|
426 |
model_sampling_top_k
|
427 |
],
|
428 |
-
[
|
|
|
429 |
output_plot,
|
430 |
output_midi
|
431 |
]
|
@@ -442,7 +453,8 @@ with gr.Blocks() as demo:
|
|
442 |
model_temperature,
|
443 |
model_sampling_top_k
|
444 |
],
|
445 |
-
[
|
|
|
446 |
output_plot,
|
447 |
output_midi
|
448 |
],
|
|
|
236 |
print('Source melody patch:', melody_patch)
|
237 |
print('Use nth melody note:', use_nth_note)
|
238 |
print('Model temperature:', model_temperature)
|
239 |
+
print('Model top k:', model_sampling_top_k)
|
240 |
|
241 |
print('=' * 70)
|
242 |
|
|
|
245 |
print('Prepping melody...')
|
246 |
|
247 |
if input_midi:
|
248 |
+
inp_mel = 'Custom MIDI'
|
249 |
score, score_list = load_midi(input_midi.name, melody_patch, use_nth_note)
|
250 |
|
251 |
else:
|
|
|
352 |
|
353 |
#========================================================
|
354 |
|
355 |
+
output_title = str(inp_mel)
|
356 |
output_midi = str(new_fn)
|
357 |
output_audio = (16000, audio)
|
358 |
|
359 |
output_plot = TMIDIX.plot_ms_SONG(song_f, plot_title=output_midi, return_plt=True)
|
360 |
|
361 |
print('Output MIDI file name:', output_midi)
|
362 |
+
print('Output MIDI melody title:', output_title)
|
363 |
print('=' * 70)
|
364 |
|
365 |
#========================================================
|
|
|
369 |
print('-' * 70)
|
370 |
print('Req execution time:', (reqtime.time() - start_time), 'sec')
|
371 |
|
372 |
+
return output_title, output_audio, output_plot, output_midi
|
373 |
|
374 |
#==================================================================================
|
375 |
|
|
|
401 |
|
402 |
gr.Markdown("## Upload source melody MIDI or enter a search query for a sample melody below")
|
403 |
|
404 |
+
input_midi = gr.File(label="Input MIDI",
|
405 |
+
file_types=[".midi", ".mid", ".kar"],
|
406 |
+
info='Custom MIDI overrides search querry below'
|
407 |
+
)
|
408 |
|
409 |
+
input_melody = gr.Textbox(value="Hotel California",
|
410 |
+
label="Popular melodies database search query",
|
411 |
+
info='If the query is not found, random melody will be selected'
|
412 |
+
)
|
413 |
|
414 |
gr.Markdown("## Generation options")
|
415 |
|
|
|
421 |
generate_btn = gr.Button("Generate", variant="primary")
|
422 |
|
423 |
gr.Markdown("## Generation results")
|
424 |
+
|
425 |
+
output_title = gr.Textbox(label="MIDI melody title")
|
426 |
output_audio = gr.Audio(label="MIDI audio", format="wav", elem_id="midi_audio")
|
427 |
output_plot = gr.Plot(label="MIDI score plot")
|
428 |
output_midi = gr.File(label="MIDI file", file_types=[".mid"])
|
|
|
435 |
model_temperature,
|
436 |
model_sampling_top_k
|
437 |
],
|
438 |
+
[output_title,
|
439 |
+
output_audio,
|
440 |
output_plot,
|
441 |
output_midi
|
442 |
]
|
|
|
453 |
model_temperature,
|
454 |
model_sampling_top_k
|
455 |
],
|
456 |
+
[output_title,
|
457 |
+
output_audio,
|
458 |
output_plot,
|
459 |
output_midi
|
460 |
],
|