Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -472,36 +472,6 @@ def add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern):
|
|
472 |
|
473 |
|
474 |
|
475 |
-
def add_intro_arpeggio(model_name, mid_seq):
|
476 |
-
tokenizer = models[model_name].tokenizer
|
477 |
-
sequence = ['C', 'D', 'Am', 'G']
|
478 |
-
pattern = [0, 1, 2, 1] # Root, Third, Fifth, Third
|
479 |
-
return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
|
480 |
-
|
481 |
-
def add_verse_arpeggio(model_name, mid_seq):
|
482 |
-
tokenizer = models[model_name].tokenizer
|
483 |
-
sequence = ['D', 'C', 'Am', 'G']
|
484 |
-
pattern = [0, 2, 1, 2] # Root, Fifth, Third, Fifth
|
485 |
-
return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
|
486 |
-
|
487 |
-
def add_chorus_arpeggio(model_name, mid_seq):
|
488 |
-
tokenizer = models[model_name].tokenizer
|
489 |
-
sequence = ['G', 'D', 'Am', 'C']
|
490 |
-
pattern = [0, 1, 2, 1, 0, 2] # Root, Third, Fifth, Third, Root, Fifth
|
491 |
-
return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
|
492 |
-
|
493 |
-
def add_outro_arpeggio(model_name, mid_seq):
|
494 |
-
tokenizer = models[model_name].tokenizer
|
495 |
-
sequence = ['Am', 'G', 'D', 'C']
|
496 |
-
pattern = [2, 1, 0, 1] # Fifth, Third, Root, Third
|
497 |
-
return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
|
498 |
-
|
499 |
-
arpeggio_intro.click(add_intro_arpeggio, [input_model, output_midi_seq], output_midi_seq)
|
500 |
-
arpeggio_verse.click(add_verse_arpeggio, [input_model, output_midi_seq], output_midi_seq)
|
501 |
-
arpeggio_chorus.click(add_chorus_arpeggio, [input_model, output_midi_seq], output_midi_seq)
|
502 |
-
arpeggio_outro.click(add_outro_arpeggio, [input_model, output_midi_seq], output_midi_seq)
|
503 |
-
|
504 |
-
|
505 |
with gr.Tabs():
|
506 |
with gr.TabItem("custom prompt") as tab1:
|
507 |
input_instruments = gr.Dropdown(label="🪗instruments (auto if empty)", choices=list(patch2number.keys()),
|
@@ -565,6 +535,41 @@ def add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern):
|
|
565 |
)
|
566 |
undo_btn = gr.Button("undo the last continuation")
|
567 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
tab1.select(lambda: 0, None, tab_select, queue=False)
|
569 |
tab2.select(lambda: 1, None, tab_select, queue=False)
|
570 |
tab3.select(lambda: 2, None, tab_select, queue=False)
|
|
|
472 |
|
473 |
|
474 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
with gr.Tabs():
|
476 |
with gr.TabItem("custom prompt") as tab1:
|
477 |
input_instruments = gr.Dropdown(label="🪗instruments (auto if empty)", choices=list(patch2number.keys()),
|
|
|
535 |
)
|
536 |
undo_btn = gr.Button("undo the last continuation")
|
537 |
|
538 |
+
|
539 |
+
|
540 |
+
|
541 |
+
def add_intro_arpeggio(model_name, mid_seq):
|
542 |
+
tokenizer = models[model_name].tokenizer
|
543 |
+
sequence = ['C', 'D', 'Am', 'G']
|
544 |
+
pattern = [0, 1, 2, 1] # Root, Third, Fifth, Third
|
545 |
+
return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
|
546 |
+
|
547 |
+
def add_verse_arpeggio(model_name, mid_seq):
|
548 |
+
tokenizer = models[model_name].tokenizer
|
549 |
+
sequence = ['D', 'C', 'Am', 'G']
|
550 |
+
pattern = [0, 2, 1, 2] # Root, Fifth, Third, Fifth
|
551 |
+
return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
|
552 |
+
|
553 |
+
def add_chorus_arpeggio(model_name, mid_seq):
|
554 |
+
tokenizer = models[model_name].tokenizer
|
555 |
+
sequence = ['G', 'D', 'Am', 'C']
|
556 |
+
pattern = [0, 1, 2, 1, 0, 2] # Root, Third, Fifth, Third, Root, Fifth
|
557 |
+
return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
|
558 |
+
|
559 |
+
def add_outro_arpeggio(model_name, mid_seq):
|
560 |
+
tokenizer = models[model_name].tokenizer
|
561 |
+
sequence = ['Am', 'G', 'D', 'C']
|
562 |
+
pattern = [2, 1, 0, 1] # Fifth, Third, Root, Third
|
563 |
+
return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
|
564 |
+
|
565 |
+
arpeggio_intro.click(add_intro_arpeggio, [input_model, output_midi_seq], output_midi_seq)
|
566 |
+
arpeggio_verse.click(add_verse_arpeggio, [input_model, output_midi_seq], output_midi_seq)
|
567 |
+
arpeggio_chorus.click(add_chorus_arpeggio, [input_model, output_midi_seq], output_midi_seq)
|
568 |
+
arpeggio_outro.click(add_outro_arpeggio, [input_model, output_midi_seq], output_midi_seq)
|
569 |
+
|
570 |
+
|
571 |
+
|
572 |
+
|
573 |
tab1.select(lambda: 0, None, tab_select, queue=False)
|
574 |
tab2.select(lambda: 1, None, tab_select, queue=False)
|
575 |
tab3.select(lambda: 2, None, tab_select, queue=False)
|