Update handler.py
Browse files- handler.py +4 -3
handler.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
from typing import Dict, List, Any
|
2 |
-
from
|
3 |
|
4 |
|
5 |
class EndpointHandler:
|
6 |
def __init__(self, path=""):
|
7 |
-
|
8 |
|
9 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
10 |
"""
|
@@ -18,5 +18,6 @@ class EndpointHandler:
|
|
18 |
text_prompt = data.pop("inputs", data)
|
19 |
|
20 |
# run normal prediction
|
21 |
-
speech_array =
|
22 |
return speech_array
|
|
|
|
1 |
from typing import Dict, List, Any
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
|
5 |
class EndpointHandler:
|
6 |
def __init__(self, path=""):
|
7 |
+
self.model = pipeline("text-to-speech", "suno/bark")
|
8 |
|
9 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
10 |
"""
|
|
|
18 |
text_prompt = data.pop("inputs", data)
|
19 |
|
20 |
# run normal prediction
|
21 |
+
speech_array = self.model(text_prompt,forward_params={"do_sample": True})
|
22 |
return speech_array
|
23 |
+
|