camparchimedes commited on
Commit
e1d8262
·
verified ·
1 Parent(s): 81274e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -69,18 +69,18 @@ pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large"
69
  @spaces.GPU()
70
  def transcribe_audio(audio_file, batch_size=16, sample_rate =16000):
71
  # --audio file to tensor
72
-
 
73
  waveform, samples = torchaudio.load(waveform, samples)
 
74
  if waveform.ndim > 1:
75
  waveform = waveform[0, :]
76
- waveform = waveform.numpy(audio_file)
77
- samples = samples.numpy(audio_file)
78
 
79
  start_time = time.time()
80
 
81
  # --pipe it
82
- outputs = pipe(waveform, samples, sampling_rate=sample_rate, batch_size=batch_size, return_timestamps=False)
83
- text = outputs["text"]
84
 
85
  end_time = time.time()
86
 
 
69
  @spaces.GPU()
70
  def transcribe_audio(audio_file, batch_size=16, sample_rate =16000):
71
  # --audio file to tensor
72
+ waveform = waveform.numpy(audio_file)
73
+ samples = samples.numpy(audio_file)
74
  waveform, samples = torchaudio.load(waveform, samples)
75
+
76
  if waveform.ndim > 1:
77
  waveform = waveform[0, :]
 
 
78
 
79
  start_time = time.time()
80
 
81
  # --pipe it
82
+ with torch.no_grad():
83
+ outputs = pipe(waveform, samples, sampling_rate=sample_rate, batch_size=batch_size, return_timestamps=False)
84
 
85
  end_time = time.time()
86