Mylo commited on
Commit
388b9f1
1 Parent(s): 62895ea

Fix flat audio inputs

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -30,10 +30,11 @@ def clone(audio, *args):
30
  if wav.dtype == torch.int16:
31
  wav = wav.float() / 32767.0
32
 
33
- if wav.shape[0] == 2: # Stereo to mono if needed
34
- wav = wav.mean(0, keepdim=True)
35
- if wav.shape[1] == 2:
36
- wav = wav.mean(1, keepdim=False).unsqueeze(-1)
 
37
 
38
  wav = wav[-int(sr*20):] # Take only the last 20 seconds
39
 
 
30
  if wav.dtype == torch.int16:
31
  wav = wav.float() / 32767.0
32
 
33
+ if len(wav.shape) == 2:
34
+ if wav.shape[0] == 2: # Stereo to mono if needed
35
+ wav = wav.mean(0, keepdim=True)
36
+ if wav.shape[1] == 2:
37
+ wav = wav.mean(1, keepdim=False).unsqueeze(-1)
38
 
39
  wav = wav[-int(sr*20):] # Take only the last 20 seconds
40