Skip to content

Commit c426c7d

Browse files
committed
Added conditional logic that decodes base64-encoded string inputs to be compatible with the ASR task pipeline.
1 parent 4c39a6e commit c426c7d

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)