handler / handler.py
white
Create handler.py
efe8448 verified
raw
history blame
409 Bytes
from transformers import pipeline
import base64
class TTSHandler:
def __init__(self):
self.pipe = pipeline("text-to-speech", model="suno/bark")
def preprocess(self, text):
return {"inputs": text.strip()}
def inference(self, inputs):
return self.pipe(**inputs)
def postprocess(self, audio):
return {"audio": base64.b64encode(audio).decode("utf-8")}