Hendrik Schroeter commited on
Commit
2405b89
1 Parent(s): 91df5e7

Force mono

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -117,6 +117,9 @@ def demo_fn(
117
  assert tmp is not None
118
  sample, meta = tmp
119
  sample = sample[..., : 10 * meta.sample_rate] # limit to 10 seconds
 
 
 
120
  logger.info(f"Loaded sample with shape {sample.shape}")
121
  if noise_fn is not None:
122
  noise, _ = load_audio(noise_fn, sr) # type: ignore
 
117
  assert tmp is not None
118
  sample, meta = tmp
119
  sample = sample[..., : 10 * meta.sample_rate] # limit to 10 seconds
120
+ if sample.dim() > 1 and sample.shape[0] > 1:
121
+ assert sample.shape[1] > sample.shape[2], f"Expecting channels first, but got {sample.shape}"
122
+ sample = sample.mean(dim=0, keepdim=True)
123
  logger.info(f"Loaded sample with shape {sample.shape}")
124
  if noise_fn is not None:
125
  noise, _ = load_audio(noise_fn, sr) # type: ignore