NERDDISCO's picture
kale-tts-1
f21d6eb
Raw History Blame Contribute Delete
968 Bytes
"""local test of the predictor with the cog python package (no docker, no Replicate account): setup() + predict() like `cog predict` does."""
import json, sys, time, wave
ctx = sys.argv[1]; sys.path.insert(0, ctx)
import importlib.metadata as md
from predict import Predictor
t = time.perf_counter(); p = Predictor(); p.setup(); load = time.perf_counter() - t
res = {}
for m in ("kale-tts-1-nano", "kale-tts-1-tiny"):
p.predict(text="Hi.", voice="kenzie", model=m)
t = time.perf_counter(); out = p.predict(text="A volcano is a place where very hot, melted rock comes up out of the ground. Most volcanoes are hidden under the sea!", voice="amy", model=m); dt = time.perf_counter() - t
w = wave.open(str(out)); dur = w.getnframes() / w.getframerate(); res[m] = dict(audio_s=round(dur, 2), request_s=round(dt, 3), xrt=round(dur / dt, 1))
print(json.dumps(dict(runtime="replicate cog predictor (local)", cog=md.version("cog"), setup_s=round(load, 2), **res)))