anzorq commited on
Commit
3225df0
1 Parent(s): 3adb955

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -18
app.py CHANGED
@@ -123,11 +123,11 @@ def generate(prompt, steps, num_iterations, feel, seed):
123
  bg_image = outpaint(prompt, init_image, mask, steps)
124
  bg_image.save("bg_image.png")
125
 
126
- return read(wav_bytes)
127
- # with open("output.wav", "wb") as f:
128
- # f.write(wav_bytes.read())
129
 
130
- # return gr.make_waveform("output.wav", bg_image="bg_image.png", bar_count=int(duration_s*25))
131
 
132
 
133
  ###############################################
@@ -168,7 +168,7 @@ def generate_riffuse(prompt_start, steps, num_iterations, feel, prompt_end=None,
168
 
169
  if prompt_end is None:
170
  prompt_end = prompt_start
171
- if seed_start is None:
172
  seed_start = random.randint(0,4294967295)
173
  if seed_end is None:
174
  seed_end = seed_start
@@ -188,16 +188,17 @@ def generate_riffuse(prompt_start, steps, num_iterations, feel, prompt_end=None,
188
  seed_start = seed_end
189
  seed_end = seed_start + 1
190
 
191
- return read(wav_bytes)
 
192
 
193
- # mask = Image.new("RGB", (512, 512), color="white")
194
- # bg_image = outpaint(f"{prompt_start} and {prompt_end}", init_image, mask, steps)
195
- # bg_image.save("bg_image.png")
196
 
197
- # with open("output.wav", "wb") as f:
198
- # f.write(wav_bytes.read())
199
 
200
- # return gr.make_waveform("output.wav", bg_image="bg_image.png")
201
 
202
 
203
  def wav_list_to_wav(wav_list):
@@ -232,8 +233,11 @@ def on_submit(prompt_1, prompt_2, steps, num_iterations, feel, seed):
232
  def on_num_iterations_change(n, prompt_2):
233
  if n is None:
234
  return gr.update(value="")
235
- x = 5 if prompt_2 != "" else 2.5
236
- total_length = x + x * n
 
 
 
237
  return gr.update(value=f"Total length: {total_length:.2f} seconds")
238
 
239
  with gr.Blocks() as app:
@@ -257,11 +261,10 @@ with gr.Blocks() as app:
257
  info = gr.Markdown()
258
  btn_generate = gr.Button(value="Generate")
259
  with gr.Column():
260
- # video = gr.Video()
261
- audio = gr.Audio()
262
 
263
  inputs = [prompt_1, prompt_2, steps, num_iterations, feel, seed]
264
- outputs = [audio, info]
265
 
266
  num_iterations.change(on_num_iterations_change, [num_iterations, prompt_2], [info])
267
  prompt_1.submit(on_submit, inputs, outputs)
@@ -274,13 +277,13 @@ with gr.Blocks() as app:
274
  ["synthwave", "jazz", "agile", 10],
275
  ["rap battle freestyle", "", "og_beat", 10],
276
  ["techno club banger", "", "og_beat", 10],
 
277
  ["acoustic folk ballad", "", "agile", 10],
278
  ["blues guitar riff", "", "agile", 5],
279
  ["jazzy trumpet solo", "", "og_beat", 5],
280
  ["classical symphony orchestra", "", "vibes", 10],
281
  ["rock and roll power chord", "", "motorway", 5],
282
  ["soulful R&B love song", "", "marim", 10],
283
- ["reggae dub beat", "sunset chill", "og_beat", 10],
284
  ["country western twangy guitar", "", "agile", 10]],
285
  inputs=[prompt_1, prompt_2, feel, num_iterations])
286
 
 
123
  bg_image = outpaint(prompt, init_image, mask, steps)
124
  bg_image.save("bg_image.png")
125
 
126
+ # return read(wav_bytes)
127
+ with open("output.wav", "wb") as f:
128
+ f.write(wav_bytes.read())
129
 
130
+ return gr.make_waveform("output.wav", bg_image="bg_image.png", bar_count=int(duration_s*25))
131
 
132
 
133
  ###############################################
 
168
 
169
  if prompt_end is None:
170
  prompt_end = prompt_start
171
+ if seed_start is 0:
172
  seed_start = random.randint(0,4294967295)
173
  if seed_end is None:
174
  seed_end = seed_start
 
188
  seed_start = seed_end
189
  seed_end = seed_start + 1
190
 
191
+ # return read(wav_bytes)
192
+ # return wav_list_to_wav(wav_list)
193
 
194
+ mask = Image.new("RGB", (512, 512), color="white")
195
+ bg_image = outpaint(f"{prompt_start} and {prompt_end}", init_image, mask, steps)
196
+ bg_image.save("bg_image.png")
197
 
198
+ with open("output.wav", "wb") as f:
199
+ f.write(wav_list_to_wav(wav_list))
200
 
201
+ return gr.make_waveform("output.wav", bg_image="bg_image.png")
202
 
203
 
204
  def wav_list_to_wav(wav_list):
 
233
  def on_num_iterations_change(n, prompt_2):
234
  if n is None:
235
  return gr.update(value="")
236
+
237
+ if prompt_2 != "":
238
+ total_length = 5 * n
239
+ else:
240
+ total_length = 2.5 + 2.5 * n
241
  return gr.update(value=f"Total length: {total_length:.2f} seconds")
242
 
243
  with gr.Blocks() as app:
 
261
  info = gr.Markdown()
262
  btn_generate = gr.Button(value="Generate")
263
  with gr.Column():
264
+ video = gr.Video()
 
265
 
266
  inputs = [prompt_1, prompt_2, steps, num_iterations, feel, seed]
267
+ outputs = [video, info]
268
 
269
  num_iterations.change(on_num_iterations_change, [num_iterations, prompt_2], [info])
270
  prompt_1.submit(on_submit, inputs, outputs)
 
277
  ["synthwave", "jazz", "agile", 10],
278
  ["rap battle freestyle", "", "og_beat", 10],
279
  ["techno club banger", "", "og_beat", 10],
280
+ ["reggae dub beat", "sunset chill", "og_beat", 10],
281
  ["acoustic folk ballad", "", "agile", 10],
282
  ["blues guitar riff", "", "agile", 5],
283
  ["jazzy trumpet solo", "", "og_beat", 5],
284
  ["classical symphony orchestra", "", "vibes", 10],
285
  ["rock and roll power chord", "", "motorway", 5],
286
  ["soulful R&B love song", "", "marim", 10],
 
287
  ["country western twangy guitar", "", "agile", 10]],
288
  inputs=[prompt_1, prompt_2, feel, num_iterations])
289