Upload 2 files
Browse files- handler.py +4 -8
- requirements.txt +1 -1
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,10 +18,6 @@ class EndpointHandler:
|
|
18 |
text_prompt = data.pop("inputs", data)
|
19 |
|
20 |
# run normal prediction
|
21 |
-
|
22 |
-
|
23 |
-
But I also have other interests such as playing tic tac toe.
|
24 |
-
"""
|
25 |
-
audio_array = generate_audio(text_prompt)
|
26 |
-
return audio_array
|
27 |
|
|
|
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 |
|
requirements.txt
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
|
|
1 |
+
transformers
|