hoang1007 commited on
Commit
38afba8
1 Parent(s): 9f942ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -34,7 +34,9 @@ model.eval()
34
 
35
  def transcribe(audio):
36
  sample_rate, waveform = audio
37
- waveform = torch.from_numpy(waveform[:, 0]).float().unsqueeze_(0)
 
 
38
  waveform = torchaudio.functional.resample(waveform, sample_rate, 16_000)
39
 
40
  transcript = model.predict(waveform)[0]
 
34
 
35
  def transcribe(audio):
36
  sample_rate, waveform = audio
37
+ if len(waveform.shape) == 2:
38
+ waveform = waveform[:, 0]
39
+ waveform = torch.from_numpy(waveform).float().unsqueeze_(0)
40
  waveform = torchaudio.functional.resample(waveform, sample_rate, 16_000)
41
 
42
  transcript = model.predict(waveform)[0]