Update handler.py
Browse files- handler.py +4 -9
handler.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
from typing import Dict, List, Any
|
| 2 |
-
from
|
| 3 |
|
| 4 |
class EndpointHandler():
|
| 5 |
def __init__(self, path=""):
|
| 6 |
-
|
| 7 |
-
self.processor = AutoProcessor.from_pretrained("suno/bark")
|
| 8 |
|
| 9 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 10 |
"""
|
|
@@ -17,11 +16,7 @@ class EndpointHandler():
|
|
| 17 |
# get inputs
|
| 18 |
text_prompt = data.pop("inputs",data)
|
| 19 |
|
| 20 |
-
inputs = processor(text_prompt)
|
| 21 |
-
|
| 22 |
# run normal prediction
|
| 23 |
-
|
| 24 |
-
return
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
|
|
|
| 1 |
from typing import Dict, List, Any
|
| 2 |
+
from bark import SAMPLE_RATE, generate_audio, preload_models
|
| 3 |
|
| 4 |
class EndpointHandler():
|
| 5 |
def __init__(self, path=""):
|
| 6 |
+
preload_models()
|
|
|
|
| 7 |
|
| 8 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 9 |
"""
|
|
|
|
| 16 |
# get inputs
|
| 17 |
text_prompt = data.pop("inputs",data)
|
| 18 |
|
|
|
|
|
|
|
| 19 |
# run normal prediction
|
| 20 |
+
speech_array = generate_audio(text_prompt)
|
| 21 |
+
return speech_array
|
| 22 |
|
|
|
|
|
|