Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,7 +107,7 @@ print('=' * 70)
|
|
| 107 |
|
| 108 |
#==================================================================================
|
| 109 |
|
| 110 |
-
def load_midi(input_midi, melody_patch=-1):
|
| 111 |
|
| 112 |
raw_score = TMIDIX.midi2single_track_ms_score(input_midi)
|
| 113 |
|
|
@@ -128,7 +128,7 @@ def load_midi(input_midi, melody_patch=-1):
|
|
| 128 |
else:
|
| 129 |
zscore = TMIDIX.recalculate_score_timings(sp_escore_notes)
|
| 130 |
|
| 131 |
-
cscore = TMIDIX.chordify_score([1000, zscore])
|
| 132 |
|
| 133 |
score = []
|
| 134 |
|
|
@@ -160,6 +160,7 @@ def load_midi(input_midi, melody_patch=-1):
|
|
| 160 |
def Generate_Accompaniment(input_midi,
|
| 161 |
generation_type,
|
| 162 |
melody_patch,
|
|
|
|
| 163 |
model_temperature
|
| 164 |
):
|
| 165 |
|
|
@@ -252,13 +253,14 @@ def Generate_Accompaniment(input_midi,
|
|
| 252 |
print('Input MIDI file name:', fn)
|
| 253 |
print('Generation type:', generation_type)
|
| 254 |
print('Source melody patch:', melody_patch)
|
|
|
|
| 255 |
print('Model temperature:', model_temperature)
|
| 256 |
|
| 257 |
print('=' * 70)
|
| 258 |
|
| 259 |
#==================================================================
|
| 260 |
|
| 261 |
-
score, score_list = load_midi(input_midi.name)
|
| 262 |
|
| 263 |
print('Sample score events', score[:12])
|
| 264 |
|
|
@@ -453,6 +455,7 @@ with gr.Blocks() as demo:
|
|
| 453 |
|
| 454 |
generation_type = gr.Radio(["Guided", "Freestyle"], value="Guided", label="Generation type")
|
| 455 |
melody_patch = gr.Slider(-1, 127, value=-1, step=1, label="Source melody MIDI patch")
|
|
|
|
| 456 |
model_temperature = gr.Slider(0.1, 1, value=0.9, step=0.01, label="Model temperature")
|
| 457 |
|
| 458 |
generate_btn = gr.Button("Generate", variant="primary")
|
|
@@ -467,6 +470,7 @@ with gr.Blocks() as demo:
|
|
| 467 |
[input_midi,
|
| 468 |
generation_type,
|
| 469 |
melody_patch,
|
|
|
|
| 470 |
model_temperature
|
| 471 |
],
|
| 472 |
[output_audio,
|
|
@@ -476,13 +480,14 @@ with gr.Blocks() as demo:
|
|
| 476 |
)
|
| 477 |
|
| 478 |
gr.Examples(
|
| 479 |
-
[["USSR-National-Anthem-Seed-Melody.mid", "Guided", -1, 0.9],
|
| 480 |
-
["Hotel-California-Seed-Melody.mid", "Guided", -1, 0.9],
|
| 481 |
-
["Sparks-Fly-Seed-Melody.mid", "Guided", -1, 0.9]
|
| 482 |
],
|
| 483 |
[input_midi,
|
| 484 |
generation_type,
|
| 485 |
melody_patch,
|
|
|
|
| 486 |
model_temperature
|
| 487 |
],
|
| 488 |
[output_audio,
|
|
|
|
| 107 |
|
| 108 |
#==================================================================================
|
| 109 |
|
| 110 |
+
def load_midi(input_midi, melody_patch=-1, use_nth_note):
|
| 111 |
|
| 112 |
raw_score = TMIDIX.midi2single_track_ms_score(input_midi)
|
| 113 |
|
|
|
|
| 128 |
else:
|
| 129 |
zscore = TMIDIX.recalculate_score_timings(sp_escore_notes)
|
| 130 |
|
| 131 |
+
cscore = TMIDIX.chordify_score([1000, zscore])[:use_nth_note]
|
| 132 |
|
| 133 |
score = []
|
| 134 |
|
|
|
|
| 160 |
def Generate_Accompaniment(input_midi,
|
| 161 |
generation_type,
|
| 162 |
melody_patch,
|
| 163 |
+
use_nth_note,
|
| 164 |
model_temperature
|
| 165 |
):
|
| 166 |
|
|
|
|
| 253 |
print('Input MIDI file name:', fn)
|
| 254 |
print('Generation type:', generation_type)
|
| 255 |
print('Source melody patch:', melody_patch)
|
| 256 |
+
print('Use nth melody note:', use_nth_note)
|
| 257 |
print('Model temperature:', model_temperature)
|
| 258 |
|
| 259 |
print('=' * 70)
|
| 260 |
|
| 261 |
#==================================================================
|
| 262 |
|
| 263 |
+
score, score_list = load_midi(input_midi.name, melody_patch, use_nth_note)
|
| 264 |
|
| 265 |
print('Sample score events', score[:12])
|
| 266 |
|
|
|
|
| 455 |
|
| 456 |
generation_type = gr.Radio(["Guided", "Freestyle"], value="Guided", label="Generation type")
|
| 457 |
melody_patch = gr.Slider(-1, 127, value=-1, step=1, label="Source melody MIDI patch")
|
| 458 |
+
use_nth_note = gr.Slider(1, 8, value=1, step=1, label="Use each nth melody note")
|
| 459 |
model_temperature = gr.Slider(0.1, 1, value=0.9, step=0.01, label="Model temperature")
|
| 460 |
|
| 461 |
generate_btn = gr.Button("Generate", variant="primary")
|
|
|
|
| 470 |
[input_midi,
|
| 471 |
generation_type,
|
| 472 |
melody_patch,
|
| 473 |
+
use_nth_note,
|
| 474 |
model_temperature
|
| 475 |
],
|
| 476 |
[output_audio,
|
|
|
|
| 480 |
)
|
| 481 |
|
| 482 |
gr.Examples(
|
| 483 |
+
[["USSR-National-Anthem-Seed-Melody.mid", "Guided", -1, 1, 0.9],
|
| 484 |
+
["Hotel-California-Seed-Melody.mid", "Guided", -1, 1, 0.9],
|
| 485 |
+
["Sparks-Fly-Seed-Melody.mid", "Guided", -1, 1, 0.9]
|
| 486 |
],
|
| 487 |
[input_midi,
|
| 488 |
generation_type,
|
| 489 |
melody_patch,
|
| 490 |
+
use_nth_note,
|
| 491 |
model_temperature
|
| 492 |
],
|
| 493 |
[output_audio,
|