wrice commited on
Commit
316bc64
1 Parent(s): bcee150

handle multi-channel audio

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -26,8 +26,10 @@ def denoise(model_name, inputs):
26
  print(f"Audio shape: {audio.shape}")
27
  print(f"Sample rate: {sr}")
28
 
29
- if audio.shape[1] > 1:
30
- audio = audio.mean(1, keepdim=True)
 
 
31
 
32
  if sr != model.config.sample_rate:
33
  audio = torchaudio.functional.resample(audio, sr, model.config.sample_rate)
 
26
  print(f"Audio shape: {audio.shape}")
27
  print(f"Sample rate: {sr}")
28
 
29
+ if audio.shape[-1] > 1:
30
+ audio = audio.mean(-1, keepdim=True)
31
+
32
+ print(f"Audio shape: {audio.shape}")
33
 
34
  if sr != model.config.sample_rate:
35
  audio = torchaudio.functional.resample(audio, sr, model.config.sample_rate)