srd4 commited on
Commit
15c5304
·
verified ·
1 Parent(s): ef46aa8

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +3 -2
handler.py CHANGED
@@ -4,9 +4,10 @@ import io
4
 
5
  class EndpointHandler:
6
  def __init__(self, model_dir=None):
7
- # If a model_dir is provided, use it; otherwise, default to 'large-v2'.
8
  model_size = "large-v2" if model_dir is None else model_dir
9
- self.model = WhisperModel(model_size, device="cpu")
 
10
 
11
  def __call__(self, data: Dict) -> Dict[str, str]:
12
  # Process the input data expected to be in 'inputs' key containing audio file bytes
 
4
 
5
  class EndpointHandler:
6
  def __init__(self, model_dir=None):
7
+ # Set model size, assuming installation has been done with appropriate model files and setup
8
  model_size = "large-v2" if model_dir is None else model_dir
9
+ # Change to 'cuda' to use the GPU, and set compute_type for faster computation
10
+ self.model = WhisperModel(model_size, device="cuda", compute_type="float16")
11
 
12
  def __call__(self, data: Dict) -> Dict[str, str]:
13
  # Process the input data expected to be in 'inputs' key containing audio file bytes