Update handler.py
Browse files- handler.py +7 -5
handler.py
CHANGED
|
@@ -14,16 +14,18 @@ class EndpointHandler:
|
|
| 14 |
"""
|
| 15 |
Args:
|
| 16 |
data (:obj:):
|
| 17 |
-
includes the
|
|
|
|
|
|
|
| 18 |
Return:
|
| 19 |
-
|
| 20 |
"""
|
| 21 |
# process input
|
| 22 |
inputs = data.pop("inputs", data)
|
| 23 |
-
audio_nparray = ffmpeg_read(inputs, 16000)
|
| 24 |
# Retrieve custom arguments
|
| 25 |
-
batched = data.pop("batched", True)
|
| 26 |
-
params = data.pop("parameters", {})
|
| 27 |
if batched:
|
| 28 |
segments, info = self.batched_model.transcribe(audio_nparray, **params)
|
| 29 |
else:
|
|
|
|
| 14 |
"""
|
| 15 |
Args:
|
| 16 |
data (:obj:):
|
| 17 |
+
includes the base64 encoded audio file as 'inputs'
|
| 18 |
+
whether to use batching as the 'batched' argument
|
| 19 |
+
and any additional arguments as a 'parameters' dict
|
| 20 |
Return:
|
| 21 |
+
segments of transcribed text, joined
|
| 22 |
"""
|
| 23 |
# process input
|
| 24 |
inputs = data.pop("inputs", data)
|
| 25 |
+
audio_nparray = ffmpeg_read(inputs, 16000) # read the encoded audio and convert at 16k
|
| 26 |
# Retrieve custom arguments
|
| 27 |
+
batched = data.pop("batched", True) # default is True if not specified
|
| 28 |
+
params = data.pop("parameters", {}) # all parameters for the model
|
| 29 |
if batched:
|
| 30 |
segments, info = self.batched_model.transcribe(audio_nparray, **params)
|
| 31 |
else:
|