Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -260,13 +260,15 @@ def Generate_Accompaniment(input_midi,
|
|
260 |
start_time = reqtime.time()
|
261 |
print('=' * 70)
|
262 |
|
263 |
-
|
264 |
-
fn1 = fn.split('.')[0]
|
265 |
|
266 |
print('=' * 70)
|
267 |
print('Requested settings:')
|
268 |
print('=' * 70)
|
269 |
-
|
|
|
|
|
|
|
270 |
print('Input sample melody:', input_melody)
|
271 |
print('Generation type:', generation_type)
|
272 |
print('Source melody patch:', melody_patch)
|
@@ -277,13 +279,24 @@ def Generate_Accompaniment(input_midi,
|
|
277 |
|
278 |
#==================================================================
|
279 |
|
280 |
-
if
|
281 |
score, score_list = load_midi(input_midi.name, melody_patch, use_nth_note)
|
282 |
|
283 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
score_list = popular_hook_melodies[[m[0] for m in popular_hook_melodies].index(input_melody)][1]
|
285 |
score = TMIDIX.flatten(score)
|
286 |
|
|
|
|
|
287 |
print('Sample score events', score[:12])
|
288 |
|
289 |
#==================================================================
|
@@ -473,7 +486,7 @@ with gr.Blocks() as demo:
|
|
473 |
|
474 |
input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
|
475 |
|
476 |
-
input_melody = gr.
|
477 |
|
478 |
gr.Markdown("## Generation options")
|
479 |
|
|
|
260 |
start_time = reqtime.time()
|
261 |
print('=' * 70)
|
262 |
|
263 |
+
|
|
|
264 |
|
265 |
print('=' * 70)
|
266 |
print('Requested settings:')
|
267 |
print('=' * 70)
|
268 |
+
if input_midi:
|
269 |
+
fn = os.path.basename(input_midi)
|
270 |
+
fn1 = fn.split('.')[0]
|
271 |
+
print('Input MIDI file name:', fn)
|
272 |
print('Input sample melody:', input_melody)
|
273 |
print('Generation type:', generation_type)
|
274 |
print('Source melody patch:', melody_patch)
|
|
|
279 |
|
280 |
#==================================================================
|
281 |
|
282 |
+
if input_midi:
|
283 |
score, score_list = load_midi(input_midi.name, melody_patch, use_nth_note)
|
284 |
|
285 |
else:
|
286 |
+
mel_list = [m[0].lower() for m in popular_hook_melodies]
|
287 |
+
|
288 |
+
inp_mel = random.choice(mel_list).title()
|
289 |
+
|
290 |
+
for m in mel_list:
|
291 |
+
if input_melody.lower().strip() in m:
|
292 |
+
inp_mel = m.title()
|
293 |
+
break
|
294 |
+
|
295 |
score_list = popular_hook_melodies[[m[0] for m in popular_hook_melodies].index(input_melody)][1]
|
296 |
score = TMIDIX.flatten(score)
|
297 |
|
298 |
+
print('Selected melody:', inp_mel)
|
299 |
+
|
300 |
print('Sample score events', score[:12])
|
301 |
|
302 |
#==================================================================
|
|
|
486 |
|
487 |
input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
|
488 |
|
489 |
+
input_melody = gr.Texbox(value="Hotel California", label="Popular melodies database search query")
|
490 |
|
491 |
gr.Markdown("## Generation options")
|
492 |
|