Surn commited on
Commit
c4f500c
·
1 Parent(s): 3f25cf7

Update shortened duration

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -243,8 +243,8 @@ def predict(model, text, melody_filepath, duration, dimension, topk, topp, tempe
243
  try:
244
  if melody and ("melody" in model):
245
  # return excess duration, load next model and continue in loop structure building up output_segments
246
- if duration > segment_duration:
247
- output_segments, duration = generate_music_segments(text, melody, seed, MODEL, duration, overlap, MODEL.lm.cfg.dataset.segment_duration, prompt_index, harmony_only, progress=gr.Progress(track_tqdm=True))
248
  else:
249
  # pure original code
250
  sr, melody = melody[0], torch.from_numpy(melody[1]).to(MODEL.device).float().t().unsqueeze(0)
@@ -494,7 +494,7 @@ def ui(**kwargs):
494
  melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title, model,topp, temperature, cfg_coef, segment_length], outputs=[title, prompt_index , model, topp, temperature, cfg_coef], api_name="melody_filepath_change", queue=False)
495
  reuse_seed.click(fn=lambda x: x, inputs=[seed_used], outputs=[seed], queue=False, api_name="reuse_seed_click")
496
  autoplay_cb.change(fn=lambda x: gr.update(autoplay=x), inputs=[autoplay_cb], outputs=[output], queue=False, api_name="autoplay_cb_change")
497
- segment_length.change(fn=load_melody_filepath, queue=False, api_name="segment_length_change", trigger_mode="once", inputs=[melody_filepath, title, model,topp, temperature, cfg_coef, segment_length], outputs=[title, prompt_index , model, topp, temperature, cfg_coef], show_progress="minimal")
498
 
499
  gr.Examples(
500
  examples=[
 
243
  try:
244
  if melody and ("melody" in model):
245
  # return excess duration, load next model and continue in loop structure building up output_segments
246
+ if duration > MODEL.duration:
247
+ output_segments, duration = generate_music_segments(text, melody, seed, MODEL, duration, overlap, MODEL.duration, prompt_index, harmony_only, progress=gr.Progress(track_tqdm=True))
248
  else:
249
  # pure original code
250
  sr, melody = melody[0], torch.from_numpy(melody[1]).to(MODEL.device).float().t().unsqueeze(0)
 
494
  melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title, model,topp, temperature, cfg_coef, segment_length], outputs=[title, prompt_index , model, topp, temperature, cfg_coef], api_name="melody_filepath_change", queue=False)
495
  reuse_seed.click(fn=lambda x: x, inputs=[seed_used], outputs=[seed], queue=False, api_name="reuse_seed_click")
496
  autoplay_cb.change(fn=lambda x: gr.update(autoplay=x), inputs=[autoplay_cb], outputs=[output], queue=False, api_name="autoplay_cb_change")
497
+ segment_length.release(fn=load_melody_filepath, queue=False, api_name="segment_length_change", trigger_mode="once", inputs=[melody_filepath, title, model,topp, temperature, cfg_coef, segment_length], outputs=[title, prompt_index , model, topp, temperature, cfg_coef], show_progress="minimal")
498
 
499
  gr.Examples(
500
  examples=[