botarioAcc commited on
Commit
16ff511
·
verified ·
1 Parent(s): 36c93f3

add spaces library

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import time
2
  import os
3
 
@@ -20,7 +21,9 @@ if LANGUAGE not in SUPPORTED_LANGUAGES:
20
  else:
21
  MODEL_PATH = MODEL_PATHS[LANGUAGE]
22
 
23
- wave2vec_pipeline = pipeline(
 
 
24
  "automatic-speech-recognition",
25
  model=MODEL_PATH,
26
  device=0 if torch.cuda.is_available() else -1,
@@ -30,6 +33,8 @@ wave2vec_pipeline = pipeline(
30
  token=os.getenv("HF_TOKEN"),
31
  )
32
 
 
 
33
 
34
  def transcribe_gradio(audio_path: str | None) -> str:
35
  """
 
1
+ import spaces
2
  import time
3
  import os
4
 
 
21
  else:
22
  MODEL_PATH = MODEL_PATHS[LANGUAGE]
23
 
24
+ @spaces.GPU
25
+ def init_pipeline():
26
+ return pipeline(
27
  "automatic-speech-recognition",
28
  model=MODEL_PATH,
29
  device=0 if torch.cuda.is_available() else -1,
 
33
  token=os.getenv("HF_TOKEN"),
34
  )
35
 
36
+ wave2vec_pipeline = init_pipeline()
37
+
38
 
39
  def transcribe_gradio(audio_path: str | None) -> str:
40
  """