Update handler.py
Browse files- handler.py +8 -1
handler.py
CHANGED
@@ -10,7 +10,14 @@ class EndpointHandler:
|
|
10 |
self.model = WhisperModel(model_size, device="cuda", compute_type="float16")
|
11 |
|
12 |
def __call__(self, data: Dict) -> Dict[str, str]:
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# Compile the results into a text string and extract language information
|
16 |
# Strip whitespace from each segment before joining them
|
|
|
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
|
14 |
+
audio_bytes = data["inputs"]
|
15 |
+
|
16 |
+
# Convert bytes to a file-like object
|
17 |
+
audio_file = io.BytesIO(audio_bytes)
|
18 |
+
|
19 |
+
# Perform transcription using the model
|
20 |
+
segments, info = self.model.transcribe(audio_file)
|
21 |
|
22 |
# Compile the results into a text string and extract language information
|
23 |
# Strip whitespace from each segment before joining them
|