bark / handler.py
H-H-E's picture
Update handler.py
072ee69
raw
history blame
612 Bytes
from typing import Dict, List, Any
from bark import SAMPLE_RATE, generate_audio, preload_models
class EndpointHandler():
def __init__(self, path=""):
preload_models()
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
"""
data args:
inputs (:obj: `str`)
date (:obj: `str`)
Return:
A :obj:`list` | `dict`: will be serialized and returned
"""
# get inputs
text_prompt = data.pop("inputs",data)
# run normal prediction
speech_array = generate_audio(text_prompt)
return speech_array