Update handler.py
Browse files- handler.py +8 -4
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,6 +18,10 @@ class EndpointHandler:
|
|
| 18 |
text_prompt = data.pop("inputs", data)
|
| 19 |
|
| 20 |
# run normal prediction
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
|
|
|
| 1 |
from typing import Dict, List, Any
|
| 2 |
+
from bark import SAMPLE_RATE, generate_audio, preload_models
|
| 3 |
|
| 4 |
|
| 5 |
class EndpointHandler:
|
| 6 |
def __init__(self, path=""):
|
| 7 |
+
preload_models()
|
| 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 |
+
text_prompt = """
|
| 22 |
+
Hello, my name is Suno. And, uh — and I like pizza. [laughs]
|
| 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 |
|