awacke1 commited on
Commit
433f901
1 Parent(s): 64015bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -30
app.py CHANGED
@@ -468,6 +468,40 @@ def add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern):
468
  input_model = gr.Dropdown(label="select model", choices=list(models.keys()),
469
  type="value", value=list(models.keys())[0])
470
  tab_select = gr.State(value=0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
  with gr.Tabs():
472
  with gr.TabItem("custom prompt") as tab1:
473
  input_instruments = gr.Dropdown(label="🪗instruments (auto if empty)", choices=list(patch2number.keys()),
@@ -584,36 +618,6 @@ def add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern):
584
  [output_midi_seq, output_continuation_state, js_msg], queue=False)
585
 
586
 
587
-
588
- def add_intro_arpeggio(model_name, mid_seq):
589
- tokenizer = models[model_name].tokenizer
590
- sequence = ['C', 'D', 'Am', 'G']
591
- pattern = [0, 1, 2, 1] # Root, Third, Fifth, Third
592
- return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
593
-
594
- def add_verse_arpeggio(model_name, mid_seq):
595
- tokenizer = models[model_name].tokenizer
596
- sequence = ['D', 'C', 'Am', 'G']
597
- pattern = [0, 2, 1, 2] # Root, Fifth, Third, Fifth
598
- return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
599
-
600
- def add_chorus_arpeggio(model_name, mid_seq):
601
- tokenizer = models[model_name].tokenizer
602
- sequence = ['G', 'D', 'Am', 'C']
603
- pattern = [0, 1, 2, 1, 0, 2] # Root, Third, Fifth, Third, Root, Fifth
604
- return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
605
-
606
- def add_outro_arpeggio(model_name, mid_seq):
607
- tokenizer = models[model_name].tokenizer
608
- sequence = ['Am', 'G', 'D', 'C']
609
- pattern = [2, 1, 0, 1] # Fifth, Third, Root, Third
610
- return add_arpeggio_sequence(tokenizer, mid_seq, sequence, pattern)
611
-
612
- arpeggio_intro.click(add_intro_arpeggio, [input_model, output_midi_seq], output_midi_seq)
613
- arpeggio_verse.click(add_verse_arpeggio, [input_model, output_midi_seq], output_midi_seq)
614
- arpeggio_chorus.click(add_chorus_arpeggio, [input_model, output_midi_seq], output_midi_seq)
615
- arpeggio_outro.click(add_outro_arpeggio, [input_model, output_midi_seq], output_midi_seq)
616
-
617
 
618
  app.queue().launch(server_port=opt.port, share=opt.share, inbrowser=True, ssr_mode=False)
619
  thread_pool.shutdown()
 
468
  input_model = gr.Dropdown(label="select model", choices=list(models.keys()),
469
  type="value", value=list(models.keys())[0])
470
  tab_select = gr.State(value=0)
471
+
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()),
 
618
  [output_midi_seq, output_continuation_state, js_msg], queue=False)
619
 
620
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
621
 
622
  app.queue().launch(server_port=opt.port, share=opt.share, inbrowser=True, ssr_mode=False)
623
  thread_pool.shutdown()