Update handler.py
Browse files- 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,
|
6 |
-
#
|
7 |
-
|
|
|
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 |
|