3loi commited on
Commit
ff9ea0c
1 Parent(s): d3aaef0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -19,8 +19,10 @@ def classify_audio(audio_file):
19
 
20
  sr, raw_wav = audio_file
21
 
22
- y = raw_wav.astype(np.float32)
23
- y /= np.max(np.abs(y))
 
 
24
 
25
 
26
  norm_wav = (y - mean) / (std+0.000001)
@@ -31,6 +33,8 @@ def classify_audio(audio_file):
31
  pred = model(wavs, mask).detach().numpy()
32
 
33
  output = ''
 
 
34
  # for i, audio_pred in enumerate(pred):
35
  # output[i] = {}
36
  for att_i, att_val in enumerate(pred[0]):
 
19
 
20
  sr, raw_wav = audio_file
21
 
22
+ #y = raw_wav.astype(np.float32)
23
+ #y /= np.max(np.abs(y))
24
+
25
+ y = raw_wav.astype(np.float32, order='C') / np.iinfo(raw_wav.dtype).max
26
 
27
 
28
  norm_wav = (y - mean) / (std+0.000001)
 
33
  pred = model(wavs, mask).detach().numpy()
34
 
35
  output = ''
36
+ if sr != 16000:
37
+ output += "{} sampling rate is uncompatible. The model was trained on {} sampleing rate\n".format(sr, 16000)
38
  # for i, audio_pred in enumerate(pred):
39
  # output[i] = {}
40
  for att_i, att_val in enumerate(pred[0]):