fffiloni commited on
Commit
2699d44
·
1 Parent(s): e1d98c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -40,12 +40,12 @@ def load_model(version):
40
  return MusicGen.get_pretrained(version)
41
 
42
 
43
- def predict(music_prompt, melody, duration, model):
44
  text = music_prompt
45
  global MODEL
46
  topk = int(250)
47
- if MODEL is None or MODEL.name != model:
48
- MODEL = load_model(model)
49
 
50
  if duration > MODEL.lm.cfg.dataset.segment_duration:
51
  raise gr.Error("MusicGen currently supports durations of up to 30 seconds!")
@@ -111,7 +111,7 @@ with gr.Blocks(css=css) as demo:
111
  music_prompt = gr.Textbox(label="Musical Prompt", info="Describe what kind of music you wish for", interactive=True, placeholder="lofi slow bpm electro chill with organic samples")
112
  melody = gr.Audio(source="upload", type="numpy", label="Track Condition (from previous step)", interactive=False)
113
  with gr.Row():
114
- model = gr.Radio(["melody", "medium", "small", "large"], label="MusicGen Model", value="melody", interactive=True)
115
  duration = gr.Slider(minimum=1, maximum=30, value=10, step=1, label="Generated Music Duration", interactive=True)
116
  with gr.Row():
117
  submit = gr.Button("Submit")
@@ -129,37 +129,34 @@ with gr.Blocks(css=css) as demo:
129
  [
130
  "An 80s driving pop song with heavy drums and synth pads in the background",
131
  None,
132
- 10,
133
- "melody"
134
  ],
135
  [
136
  "A cheerful country song with acoustic guitars",
137
  None,
138
- 10,
139
- "large"
140
  ],
141
  [
142
  "90s rock song with electric guitar and heavy drums",
143
  None,
 
144
  ],
145
  [
146
  "a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions bpm: 130",
147
  None,
148
- 10,
149
- "melody"
150
  ],
151
  [
152
  "lofi slow bpm electro chill with organic samples",
153
  None,
154
- 10,
155
- "small"
156
  ],
157
  ],
158
- inputs=[music_prompt, melody, duration, model],
159
  outputs=[output]
160
  )
161
  load_sound_btn.click(split_process, inputs=[uploaded_sound, chosen_track], outputs=[melody])
162
- submit.click(predict, inputs=[music_prompt, melody, duration, model], outputs=[output])
163
 
164
 
165
  demo.queue(max_size=32).launch()
 
40
  return MusicGen.get_pretrained(version)
41
 
42
 
43
+ def predict(music_prompt, melody, duration):
44
  text = music_prompt
45
  global MODEL
46
  topk = int(250)
47
+ if MODEL is None or MODEL.name != "melody":
48
+ MODEL = load_model("melody")
49
 
50
  if duration > MODEL.lm.cfg.dataset.segment_duration:
51
  raise gr.Error("MusicGen currently supports durations of up to 30 seconds!")
 
111
  music_prompt = gr.Textbox(label="Musical Prompt", info="Describe what kind of music you wish for", interactive=True, placeholder="lofi slow bpm electro chill with organic samples")
112
  melody = gr.Audio(source="upload", type="numpy", label="Track Condition (from previous step)", interactive=False)
113
  with gr.Row():
114
+ #model = gr.Radio(["melody", "medium", "small", "large"], label="MusicGen Model", value="melody", interactive=True)
115
  duration = gr.Slider(minimum=1, maximum=30, value=10, step=1, label="Generated Music Duration", interactive=True)
116
  with gr.Row():
117
  submit = gr.Button("Submit")
 
129
  [
130
  "An 80s driving pop song with heavy drums and synth pads in the background",
131
  None,
132
+ 10
 
133
  ],
134
  [
135
  "A cheerful country song with acoustic guitars",
136
  None,
137
+ 10
 
138
  ],
139
  [
140
  "90s rock song with electric guitar and heavy drums",
141
  None,
142
+ 10
143
  ],
144
  [
145
  "a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions bpm: 130",
146
  None,
147
+ 10
 
148
  ],
149
  [
150
  "lofi slow bpm electro chill with organic samples",
151
  None,
152
+ 10
 
153
  ],
154
  ],
155
+ inputs=[music_prompt, melody, duration],
156
  outputs=[output]
157
  )
158
  load_sound_btn.click(split_process, inputs=[uploaded_sound, chosen_track], outputs=[melody])
159
+ submit.click(predict, inputs=[music_prompt, melody, duration], outputs=[output])
160
 
161
 
162
  demo.queue(max_size=32).launch()