wrice commited on
Commit
f74d062
1 Parent(s): 3a62ed4

handle audio with different shapes

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -20,14 +20,11 @@ def denoise(model_name, inputs):
20
  else:
21
  model = WaveUNetModel.from_pretrained(model_name)
22
  sr, audio = inputs
23
- audio = torch.from_numpy(audio)[None]
24
-
25
  audio = audio / 32768.0
26
 
27
- if audio.ndim == 2:
28
- audio = audio.permute(1, 0)
29
- else:
30
- audio = audio.permute(0, 2, 1)
31
 
32
  print(f"Audio shape: {audio.shape}")
33
  print(f"Sample rate: {sr}")
 
20
  else:
21
  model = WaveUNetModel.from_pretrained(model_name)
22
  sr, audio = inputs
23
+ audio = torch.from_numpy(audio)
 
24
  audio = audio / 32768.0
25
 
26
+ if audio.ndim == 1:
27
+ audio = audio.unsqueeze(0)
 
 
28
 
29
  print(f"Audio shape: {audio.shape}")
30
  print(f"Sample rate: {sr}")