demavior commited on
Commit
27e0d0f
·
verified ·
1 Parent(s): 9ad5b8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -27,8 +27,8 @@ def transcribe(audio):
27
  resampler = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)
28
  audio_tensor = resampler(audio_tensor)
29
 
30
- # Ensure the audio tensor is on the correct device
31
- audio_tensor = audio_tensor.to(device)
32
 
33
  pipe = pipeline(
34
  "automatic-speech-recognition",
@@ -37,9 +37,8 @@ def transcribe(audio):
37
  device=device,
38
  )
39
 
40
- prediction = pipe(audio_tensor)["text"]
41
  return prediction
42
-
43
 
44
  gradio_app = gr.Interface(
45
  fn=transcribe,
 
27
  resampler = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)
28
  audio_tensor = resampler(audio_tensor)
29
 
30
+ # Convert back to a NumPy array
31
+ audio_np = audio_tensor.cpu().numpy()
32
 
33
  pipe = pipeline(
34
  "automatic-speech-recognition",
 
37
  device=device,
38
  )
39
 
40
+ prediction = pipe(audio_np)["text"]
41
  return prediction
 
42
 
43
  gradio_app = gr.Interface(
44
  fn=transcribe,