Download runtimes/replicate-cog/predict.py from KaleComputer/kale-tts-1-tiny: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/runtimes/replicate-cog/predict.py
- Command line
-
hf download hf://KaleComputer/kale-tts-1-tiny/runtimes/replicate-cog/predict.py
-
curl -L -o predict.py https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/runtimes/replicate-cog/predict.py
1.27 kB
| """Replicate predictor for kale-tts-1: text -> 24 kHz WAV. Files next to it (make_context.sh): models/, frontend/, kale_tts.py, kale_frontend.js.""" | |
| from pathlib import Path | |
| from cog import BasePredictor, Input, Path as CogPath | |
| HERE = Path(__file__).resolve().parent | |
| VOICES = ["kenzie", "simone", "amy", "frankie", "darlene", "owen", "toby", "jack", "earl", "magnus"] | |
| class Predictor(BasePredictor): | |
| def setup(self): | |
| import sys; sys.path.insert(0, str(HERE)) | |
| from kale_tts import KaleTTS, QuickJSFrontEnd, to_wav | |
| fe = QuickJSFrontEnd(frontend_dir=HERE / "frontend", bundle=HERE / "kale_frontend.js") | |
| self.to_wav = to_wav | |
| self.tts = {m: KaleTTS(HERE / "models" / m, threads=2, frontend=fe) for m in ("kale-tts-1-nano", "kale-tts-1-tiny")} | |
| def predict(self, text: str = Input(description="English text to read aloud"), | |
| voice: str = Input(default="kenzie", choices=VOICES, description="amy and jack are British (en-gb front end), the others American"), | |
| model: str = Input(default="kale-tts-1-nano", choices=["kale-tts-1-nano", "kale-tts-1-tiny"])) -> CogPath: | |
| out = Path("/tmp/kale-tts.wav"); out.write_bytes(self.to_wav(self.tts[model].speak(text, voice=voice))); return CogPath(out) | |