MikeMpapa commited on
Commit
867ced4
1 Parent(s): c9d7e0a

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +26 -4
main.py CHANGED
@@ -6,6 +6,7 @@ from utils import (
6
  generate_song,
7
  remove_last_instrument,
8
  regenerate_last_instrument,
 
9
  change_tempo,
10
  )
11
 
@@ -17,11 +18,16 @@ os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
17
  # Genrs
18
  genres = ["ROCK", "POP", "OTHER", "R&B/SOUL", "JAZZ", "ELECTRONIC", "RANDOM"]
19
 
20
- #Artists
21
  with open('artist_names.json', 'r') as f:
22
  artist_names = json.load(f)
23
  #print("Loaded Artists names:", artist_names)
24
 
 
 
 
 
 
25
  demo = gr.Blocks()
26
 
27
 
@@ -39,11 +45,15 @@ def run():
39
  artist = gr.Dropdown(
40
  choices=artist_names, value=artist_names[0], label="Select the artist style"
41
  )
 
 
 
42
  with gr.Row():
43
  btn_from_scratch = gr.Button("🧹 Start from scratch")
44
- btn_continue = gr.Button("➡️ Continue Generation")
45
  btn_remove_last = gr.Button("↩️ Remove last instrument")
46
  btn_regenerate_last = gr.Button("🔄 Regenerate last instrument")
 
47
  with gr.Column():
48
  with gr.Group():
49
  audio_output = gr.Video(show_share_button=True)
@@ -65,7 +75,7 @@ def run():
65
  num_tokens = gr.Text(visible=False)
66
  btn_from_scratch.click(
67
  fn=generate_song,
68
- inputs=[genre, artist, temp, empty_sequence, qpm],
69
  outputs=[
70
  audio_output,
71
  midi_file,
@@ -77,7 +87,7 @@ def run():
77
  )
78
  btn_continue.click(
79
  fn=generate_song,
80
- inputs=[genre, artist, temp, text_sequence, qpm],
81
  outputs=[
82
  audio_output,
83
  midi_file,
@@ -111,6 +121,18 @@ def run():
111
  num_tokens,
112
  ],
113
  )
 
 
 
 
 
 
 
 
 
 
 
 
114
  btn_qpm.click(
115
  fn=change_tempo,
116
  inputs=[text_sequence, qpm],
 
6
  generate_song,
7
  remove_last_instrument,
8
  regenerate_last_instrument,
9
+ change_last_instrument,
10
  change_tempo,
11
  )
12
 
 
18
  # Genrs
19
  genres = ["ROCK", "POP", "OTHER", "R&B/SOUL", "JAZZ", "ELECTRONIC", "RANDOM"]
20
 
21
+ # Artists
22
  with open('artist_names.json', 'r') as f:
23
  artist_names = json.load(f)
24
  #print("Loaded Artists names:", artist_names)
25
 
26
+ # Instruments
27
+ with open('instruments.json', 'r') as f:
28
+ instruments = json.load(f)
29
+
30
+
31
  demo = gr.Blocks()
32
 
33
 
 
45
  artist = gr.Dropdown(
46
  choices=artist_names, value=artist_names[0], label="Select the artist style"
47
  )
48
+ instrument = gr.Dropdown(
49
+ choices=instruments, value=instruments[0], label="Select the instrument to be generated"
50
+ )
51
  with gr.Row():
52
  btn_from_scratch = gr.Button("🧹 Start from scratch")
53
+ btn_continue = gr.Button("➡️ Generate New Track")
54
  btn_remove_last = gr.Button("↩️ Remove last instrument")
55
  btn_regenerate_last = gr.Button("🔄 Regenerate last instrument")
56
+ btn_change_last = gr.Button("🔄 Swap last instrument")
57
  with gr.Column():
58
  with gr.Group():
59
  audio_output = gr.Video(show_share_button=True)
 
75
  num_tokens = gr.Text(visible=False)
76
  btn_from_scratch.click(
77
  fn=generate_song,
78
+ inputs=[genre, artist, instrument, temp, empty_sequence, qpm],
79
  outputs=[
80
  audio_output,
81
  midi_file,
 
87
  )
88
  btn_continue.click(
89
  fn=generate_song,
90
+ inputs=[genre, artist, instrument, temp, text_sequence, qpm],
91
  outputs=[
92
  audio_output,
93
  midi_file,
 
121
  num_tokens,
122
  ],
123
  )
124
+ btn_change_last.click(
125
+ fn=change_last_instrument,
126
+ inputs=[text_sequence, instrument, temp, qpm],
127
+ outputs=[
128
+ audio_output,
129
+ midi_file,
130
+ plot_output,
131
+ instruments_output,
132
+ text_sequence,
133
+ num_tokens,
134
+ ],
135
+ )
136
  btn_qpm.click(
137
  fn=change_tempo,
138
  inputs=[text_sequence, qpm],