srd4 commited on
Commit
bc0028f
·
verified ·
1 Parent(s): ea6e5c3

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +5 -4
handler.py CHANGED
@@ -2,11 +2,12 @@ from typing import Dict
2
  from faster_whisper import WhisperModel
3
 
4
  class EndpointHandler:
5
- def __init__(self, *args, **kwargs):
6
- # Initialize WhisperModel; assume that "large-v2" model files are in /repository
7
- self.model = WhisperModel("large-v2", device="cpu")
 
8
 
9
- def __call__(self, data: Dict) -> Dict:
10
  # Process the input data expected to be in 'inputs' key containing audio file bytes
11
  audio_bytes = data["inputs"]
12
 
 
2
  from faster_whisper import WhisperModel
3
 
4
  class EndpointHandler:
5
+ def __init__(self, model_dir=None):
6
+ # If a model_dir is provided, use it; otherwise, default to 'large-v2'.
7
+ model_size = "large-v2" if model_dir is None else model_dir
8
+ self.model = WhisperModel(model_size, device="cpu")
9
 
10
+ def __call__(self, data: Dict) -> Dict[str, str]:
11
  # Process the input data expected to be in 'inputs' key containing audio file bytes
12
  audio_bytes = data["inputs"]
13