Skip to content

Commit be06a8f

Browse files
authored
Merge pull request #116 from lopez-brau/dev/decode_base64
Implemented `inputs` decoding for compatibility with ASR task pipeline
2 parents ff2cf24 + c426c7d commit be06a8f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/huggingface_inference_toolkit/webservice_starlette.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import base64
12
import os
23
from pathlib import Path
34
from time import perf_counter
@@ -95,6 +96,14 @@ async def predict(request):
9596
f"Body needs to provide a inputs key, received: {orjson.dumps(deserialized_body)}"
9697
)
9798

99+
# Decode inputs conditioned on the task.
100+
if "parameters" in deserialized_body and HF_TASK in {
101+
"automatic-speech-recognition"
102+
}:
103+
deserialized_body["inputs"] = base64.b64decode(
104+
deserialized_body["inputs"]
105+
)
106+
98107
# check for query parameter and add them to the body
99108
if request.query_params and "parameters" not in deserialized_body:
100109
deserialized_body["parameters"] = convert_params_to_int_or_bool(

0 commit comments

Comments
 (0)