I downloaded the model locally in advance, but I found that kittentts defaults to downloading the model from Hugging Face.
Functions loaded from the local source are hoped to be added by the author later, to avoid repeatedly downloading the model.
def load_from_local(model_path, backend=None):
"""Load the model files directly from a local folder.
The folder should contain: config.json, as well as the model and voice files specified in config.json.
"""
config_path = os.path.join(model_path, "config.json")
if not os.path.exists(config_path):
raise FileNotFoundError(f"{model_path}")
with open(config_path, 'r', encoding='utf-8') as f:
config = json.load(f)
if config.get("type") not in ["ONNX1", "ONNX2"]:
raise ValueError("Unsupported model type in local config.")
onnx_path = os.path.join(model_path, config["model_file"])
voices_path = os.path.join(model_path, config["voices"])
for p in [onnx_path, voices_path]:
if not os.path.exists(p):
raise FileNotFoundError(f"{p}")
model = KittenTTS_1_Onnx(
model_path=onnx_path,
voices_path=voices_path,
speed_priors=config.get("speed_priors", {}),
voice_aliases=config.get("voice_aliases", {}),
backend=backend
)
return model
I downloaded the model locally in advance, but I found that kittentts defaults to downloading the model from Hugging Face.
Functions loaded from the local source are hoped to be added by the author later, to avoid repeatedly downloading the model.