fix handler
Browse files- handler.py +3 -11
- test.py +1 -1
handler.py
CHANGED
@@ -24,17 +24,9 @@ class EndpointHandler():
|
|
24 |
logger.error("Error generating audio for text: %s", text, exc_info=True)
|
25 |
raise e
|
26 |
|
27 |
-
def __call__(self, data: Any) -> List[
|
28 |
-
""
|
29 |
-
|
30 |
-
data (:obj:):
|
31 |
-
includes the input data and the parameters for the inference.
|
32 |
-
Return:
|
33 |
-
A :obj:`list`:. The object returned should be a list of one list like [[{"label": 0.9939950108528137}]] containing :
|
34 |
-
- "label": A string representing what the label/class is. There can be multiple labels.
|
35 |
-
- "score": A score between 0 and 1 describing how confident the model is for this label/class.
|
36 |
-
"""
|
37 |
-
input = data.pop("input", data)
|
38 |
|
39 |
audio_data, sampling_rate = self.generate_audio(input)
|
40 |
|
|
|
24 |
logger.error("Error generating audio for text: %s", text, exc_info=True)
|
25 |
raise e
|
26 |
|
27 |
+
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
28 |
+
input = data.pop("inputs", data)
|
29 |
+
# parameters = data.pop("parameters",data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
audio_data, sampling_rate = self.generate_audio(input)
|
32 |
|
test.py
CHANGED
@@ -4,7 +4,7 @@ from handler import EndpointHandler
|
|
4 |
my_handler = EndpointHandler(path=".")
|
5 |
|
6 |
# prepare sample payload
|
7 |
-
payload = {"
|
8 |
|
9 |
# test the handler
|
10 |
pred=my_handler(payload)
|
|
|
4 |
my_handler = EndpointHandler(path=".")
|
5 |
|
6 |
# prepare sample payload
|
7 |
+
payload = {"inputs": "Lowfi hiphop with deep bass"}
|
8 |
|
9 |
# test the handler
|
10 |
pred=my_handler(payload)
|