camparchimedes commited on
Commit
65ac4ea
·
verified ·
1 Parent(s): d353554

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -17,8 +17,8 @@ def convert_to_wav(audio_file):
17
 
18
  import torch
19
  from transformers import pipeline
20
-
21
- pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large")
22
 
23
  def transcribe_audio(audio_file):
24
  if audio_file.endswith(".m4a"):
@@ -26,8 +26,8 @@ def transcribe_audio(audio_file):
26
 
27
  start_time = time.time()
28
 
29
- with torch.no_grad():
30
- output = pipe(audio_file)
31
 
32
  text = output["text"]
33
  end_time = time.time()
 
17
 
18
  import torch
19
  from transformers import pipeline
20
+ device = "cuda" if torch.cuda.is_available() else "cpu"
21
+ pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large", device=device)
22
 
23
  def transcribe_audio(audio_file):
24
  if audio_file.endswith(".m4a"):
 
26
 
27
  start_time = time.time()
28
 
29
+ # with torch.no_grad():
30
+ output = pipe(audio_file)
31
 
32
  text = output["text"]
33
  end_time = time.time()