michaellee8
commited on
Commit
•
0a25040
1
Parent(s):
644ca35
fix: b64 decode
Browse files- handler.py +3 -0
handler.py
CHANGED
@@ -2,6 +2,7 @@ from typing import Dict
|
|
2 |
from transformers import pipeline
|
3 |
import requests
|
4 |
import jwt
|
|
|
5 |
|
6 |
SAMPLE_RATE = 16000
|
7 |
|
@@ -29,6 +30,8 @@ class EndpointHandler:
|
|
29 |
decoded = jwt.decode(token, PUBLIC_KEY, algorithms=["RS512"])
|
30 |
print("received input from jti=", decoded["jti"])
|
31 |
inputs = data.pop("inputs", None)
|
|
|
|
|
32 |
parameters = data.pop("parameters", {})
|
33 |
|
34 |
return self.pipeline(inputs, **parameters)
|
|
|
2 |
from transformers import pipeline
|
3 |
import requests
|
4 |
import jwt
|
5 |
+
import base64
|
6 |
|
7 |
SAMPLE_RATE = 16000
|
8 |
|
|
|
30 |
decoded = jwt.decode(token, PUBLIC_KEY, algorithms=["RS512"])
|
31 |
print("received input from jti=", decoded["jti"])
|
32 |
inputs = data.pop("inputs", None)
|
33 |
+
if isinstance(inputs, str):
|
34 |
+
inputs = base64.b64decode(inputs)
|
35 |
parameters = data.pop("parameters", {})
|
36 |
|
37 |
return self.pipeline(inputs, **parameters)
|