H-H-E commited on
Commit
3e55f57
1 Parent(s): 5ace9e2

Upload handler.py

Browse files
Files changed (1) hide show
  1. handler.py +21 -0
handler.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict, List, Any
2
+ from transformers import pipeline
3
+
4
+ class EndpointHandler():
5
+ def __init__(self, path=""):
6
+ self.pipeline = pipeline("text-to-speech", "suno/bark")
7
+
8
+ def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
9
+ """
10
+ data args:
11
+ inputs (:obj: `str`)
12
+ date (:obj: `str`)
13
+ Return:
14
+ A :obj:`list` | `dict`: will be serialized and returned
15
+ """
16
+ # get inputs
17
+ inputs = data.pop("inputs",data)
18
+
19
+ # run normal prediction
20
+ prediction = self.pipeline(inputs)
21
+ return prediction