lauraibnz commited on
Commit
431cf64
1 Parent(s): 7c54836

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -14,14 +14,30 @@ controlnet = ControlNetModel.from_pretrained("lauraibnz/midi-audioldm", torch_dt
14
  pipe = AudioLDMControlNetPipeline.from_pretrained("cvssp/audioldm-m-full", controlnet=controlnet, torch_dtype=torch_dtype)
15
  pipe = pipe.to(device)
16
 
17
- def predict(midi_file=None, prompt="", audio_length_in_s=5, controlnet_conditioning_scale=1, num_inference_steps=20):
18
  if midi_file:
19
  midi_file = midi_file.name
20
  else:
21
  midi_file = "test.mid"
22
  midi = PrettyMIDI(midi_file)
23
- audio = pipe(prompt, midi=midi, audio_length_in_s=audio_length_in_s, num_inference_steps=num_inference_steps, controlnet_conditioning_scale=float(controlnet_conditioning_scale))
 
 
 
 
 
 
 
 
24
  return (16000, audio.audios.T)
25
 
26
- demo = gr.Interface(fn=predict, inputs=[gr.File(file_types=[".mid"]), "text", gr.Slider(0, 30, value=5, step=5, label="duration (seconds)"), gr.Slider(0.0, 1.0, value=1.0, step=0.1, label="conditioning scale")], outputs="audio")
 
 
 
 
 
 
 
 
27
  demo.launch()
 
14
  pipe = AudioLDMControlNetPipeline.from_pretrained("cvssp/audioldm-m-full", controlnet=controlnet, torch_dtype=torch_dtype)
15
  pipe = pipe.to(device)
16
 
17
+ def predict(midi_file=None, prompt="", negative_prompt="", audio_length_in_s=5, controlnet_conditioning_scale=1, num_inference_steps=20, guess_mode=False):
18
  if midi_file:
19
  midi_file = midi_file.name
20
  else:
21
  midi_file = "test.mid"
22
  midi = PrettyMIDI(midi_file)
23
+ audio = pipe(
24
+ prompt,
25
+ negative_prompt=negative_prompt,
26
+ midi=midi,
27
+ audio_length_in_s=audio_length_in_s,
28
+ num_inference_steps=num_inference_steps,
29
+ controlnet_conditioning_scale=float(controlnet_conditioning_scale),
30
+ guess_mode=guess_mode
31
+ )
32
  return (16000, audio.audios.T)
33
 
34
+ demo = gr.Interface(fn=predict, inputs=[
35
+ gr.File(file_types=[".mid"]),
36
+ "text",
37
+ gr.Textbox(label="negative prompt")
38
+ gr.Slider(0, 30, value=5, step=5, label="duration (seconds)"),
39
+ gr.Slider(0.0, 1.0, value=1.0, step=0.1, label="conditioning scale"),
40
+ gr.Slider(0, 50, value=20, step=0.1, label="inference steps"),
41
+ gr.Checkbox(label="guess mode")
42
+ ], outputs="audio")
43
  demo.launch()