Vansh Chugh commited on
Commit
341c68a
·
1 Parent(s): 2be9ef6

use seconds for gap length/position controls

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -213,7 +213,7 @@ def build_gap_mask(audio_len, gap_ms, position_ms, sample_rate, device):
213
 
214
 
215
  @spaces.GPU
216
- def process_fn(input_audio_path, checkpoint_choice, gap_length_ms, gap_position_ms, steps, guidance_strength):
217
  """Fill a gap in the input audio using the selected diffusion model.
218
 
219
  Not wrapped in torch.inference_mode(): reconstruction guidance (xi > 0,
@@ -231,7 +231,8 @@ def process_fn(input_audio_path, checkpoint_choice, gap_length_ms, gap_position_
231
  audio = torch.from_numpy(audio_np).unsqueeze(0).to(DEVICE)
232
 
233
  segment = prepare_segment(audio, sr_in, sample_rate, audio_len)
234
- mask = build_gap_mask(audio_len, gap_length_ms, gap_position_ms, sample_rate, DEVICE)
 
235
 
236
  network = get_network(checkpoint_choice)
237
  args = build_args(checkpoint_choice, steps, guidance_strength)
@@ -270,9 +271,9 @@ with gr.Blocks() as demo:
270
  label="Model",
271
  info="Which checkpoint to inpaint with.",
272
  ),
273
- gr.Slider(minimum=50, maximum=3000, step=50, value=1500, label="Gap Length (ms)",
274
- info="Length of the gap to fill (default: 1500ms, per repo config)"),
275
- gr.Number(value=-1, label="Gap Position (ms)",
276
  info="Where the gap starts, from the beginning of the processed segment. -1 = centered (default, per repo config)"),
277
  gr.Slider(minimum=10, maximum=150, step=1, value=35, label="Processing Steps",
278
  info="Diffusion sampling steps (default: T=35, per repo config)"),
 
213
 
214
 
215
  @spaces.GPU
216
+ def process_fn(input_audio_path, checkpoint_choice, gap_length_s, gap_position_s, steps, guidance_strength):
217
  """Fill a gap in the input audio using the selected diffusion model.
218
 
219
  Not wrapped in torch.inference_mode(): reconstruction guidance (xi > 0,
 
231
  audio = torch.from_numpy(audio_np).unsqueeze(0).to(DEVICE)
232
 
233
  segment = prepare_segment(audio, sr_in, sample_rate, audio_len)
234
+ gap_position_ms = -1 if gap_position_s < 0 else gap_position_s * 1000
235
+ mask = build_gap_mask(audio_len, gap_length_s * 1000, gap_position_ms, sample_rate, DEVICE)
236
 
237
  network = get_network(checkpoint_choice)
238
  args = build_args(checkpoint_choice, steps, guidance_strength)
 
271
  label="Model",
272
  info="Which checkpoint to inpaint with.",
273
  ),
274
+ gr.Slider(minimum=0.05, maximum=3.0, step=0.05, value=1.5, label="Gap Length (s)",
275
+ info="Length of the gap to fill (default: 1.5s, per repo config)"),
276
+ gr.Number(value=-1, label="Gap Position (s)",
277
  info="Where the gap starts, from the beginning of the processed segment. -1 = centered (default, per repo config)"),
278
  gr.Slider(minimum=10, maximum=150, step=1, value=35, label="Processing Steps",
279
  info="Diffusion sampling steps (default: T=35, per repo config)"),