From 4e176580ce9fb0a70df6a41efab80f908f6cd6b3 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Wed, 31 Jul 2024 10:39:56 +0200 Subject: [PATCH] Fix model loading --- lib/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/main.py b/lib/main.py index 4a91a75..0a38d9d 100644 --- a/lib/main.py +++ b/lib/main.py @@ -20,13 +20,16 @@ def load_models(): dir_path = os.path.dirname(os.path.realpath(__file__)) for file in os.scandir(dir_path + "/../models/"): if os.path.isdir(file.path): - models[file.name] = lambda: WhisperModel(file.path, device="cpu") + models[file.name] = create_model_loader(file.path) for file in os.scandir(persistent_storage()): if os.path.isdir(file.path): - models[file.name] = lambda: WhisperModel(file.path, device="cpu") + models[file.name] = create_model_loader(file.path) return models +def create_model_loader(file_path): + return lambda: WhisperModel(file_path, device="cpu") + models = load_models()