Chlvnrz commited on
Commit
6642e8c
·
verified ·
1 Parent(s): d4cef17

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +62 -5
main.py CHANGED
@@ -4,6 +4,8 @@ import gradio as gr
4
 
5
  from utils import (
6
  generate_song,
 
 
7
  change_tempo,
8
  )
9
 
@@ -11,10 +13,38 @@ from utils import (
11
  os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
12
 
13
  DESCRIPTION = """
14
- <h1>🎵 Multitrack Music Generator 🎶</h1>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  """
16
 
17
- genres = ["ROCK", "POP", "JAZZ", "RANDOM"]
 
18
 
19
  demo = gr.Blocks()
20
 
@@ -22,6 +52,7 @@ demo = gr.Blocks()
22
  def run():
23
  with demo:
24
  gr.HTML(DESCRIPTION)
 
25
  with gr.Row():
26
  with gr.Column():
27
  temp = gr.Slider(
@@ -31,10 +62,12 @@ def run():
31
  choices=genres, value="POP", label="Select the genre"
32
  )
33
  with gr.Row():
34
- btn_from_scratch = gr.Button("Start")
35
- btn_continue = gr.Button("Generate More")
 
 
36
  with gr.Column():
37
- with gr.Group():
38
  audio_output = gr.Video(show_share_button=True)
39
  midi_file = gr.File()
40
  with gr.Row():
@@ -76,6 +109,30 @@ def run():
76
  num_tokens,
77
  ],
78
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  btn_qpm.click(
80
  fn=change_tempo,
81
  inputs=[text_sequence, qpm],
 
4
 
5
  from utils import (
6
  generate_song,
7
+ remove_last_instrument,
8
+ regenerate_last_instrument,
9
  change_tempo,
10
  )
11
 
 
13
  os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
14
 
15
  DESCRIPTION = """
16
+ <h1>🎵 Multitrack Midi Generator 🎶</h1>
17
+ <h3>AI-driven Music Composer: Creating Music One Instrument at a Time!</h3>
18
+ <p>This interactive application uses an AI model to generate music sequences based on a chosen genre and various user inputs. The apps constructs the piece instrument by instrument</p>
19
+ <div style="display: flex; justify-content: space-between;">
20
+ <div style="width: 45%; margin-right: 5%;">
21
+ <h2>Features:</h2>
22
+ <ul>
23
+ <li>🎼 Select the genre for the music.</li>
24
+ <li>🌡️ Use the "Temperature" slider to adjust the randomness of the music generated (higher values will produce more random outputs).</li>
25
+ <li>⏱️ Adjust the "Tempo" slider to change the speed of the music.</li>
26
+ <li>🎹 Use the buttons to generate a new song from scratch, continue generation with the current settings, remove the last added instrument, regenerate the last added instrument with a new one, or change the tempo of the current song.</li>
27
+ </ul>
28
+ </div>
29
+ <div style="width: 45%; margin-left: 5%;">
30
+ <h2>Outputs:</h2>
31
+ <p>The app outputs the following:</p>
32
+ <ul>
33
+ <li>🎧 The audio of the generated song.</li>
34
+ <li>📁 A MIDI file of the song.</li>
35
+ <li>📊 A plot of the song's sequence.</li>
36
+ <li>🎸 A list of the generated instruments.</li>
37
+ <li>📝 The text sequence of the song.</li>
38
+ </ul>
39
+ </div>
40
+ </div>
41
+ <hr style="margin-top: 2em; margin-bottom: 2em;">
42
+ <p>This application is built upon the inspiring work of <a href="https://www.linkedin.com/in/dr-tristan-behrens-734967a2" target="_blank">Dr. Tristan Behrens</a></p>
43
+ <p>Enjoy creating your own music!</p>
44
  """
45
 
46
+
47
+ genres = ["ROCK", "POP", "OTHER", "R&B/SOUL", "JAZZ", "ELECTRONIC", "RANDOM"]
48
 
49
  demo = gr.Blocks()
50
 
 
52
  def run():
53
  with demo:
54
  gr.HTML(DESCRIPTION)
55
+ gr.DuplicateButton(value="Duplicate Space for private use")
56
  with gr.Row():
57
  with gr.Column():
58
  temp = gr.Slider(
 
62
  choices=genres, value="POP", label="Select the genre"
63
  )
64
  with gr.Row():
65
+ btn_from_scratch = gr.Button("🧹 Start from scratch")
66
+ btn_continue = gr.Button("➡️ Continue Generation")
67
+ btn_remove_last = gr.Button("↩️ Remove last instrument")
68
+ btn_regenerate_last = gr.Button("🔄 Regenerate last instrument")
69
  with gr.Column():
70
+ with gr.Box():
71
  audio_output = gr.Video(show_share_button=True)
72
  midi_file = gr.File()
73
  with gr.Row():
 
109
  num_tokens,
110
  ],
111
  )
112
+ btn_remove_last.click(
113
+ fn=remove_last_instrument,
114
+ inputs=[text_sequence, qpm],
115
+ outputs=[
116
+ audio_output,
117
+ midi_file,
118
+ plot_output,
119
+ instruments_output,
120
+ text_sequence,
121
+ num_tokens,
122
+ ],
123
+ )
124
+ btn_regenerate_last.click(
125
+ fn=regenerate_last_instrument,
126
+ inputs=[text_sequence, 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],