From 3a96f60006b8e978aa679c2c075f0e79d704f85e Mon Sep 17 00:00:00 2001 From: Andreas Peldszus Date: Fri, 31 May 2024 14:45:51 +0200 Subject: [PATCH] Raise error for invalid model paths --- whisper_live/server.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/whisper_live/server.py b/whisper_live/server.py index a905c81..2accaac 100644 --- a/whisper_live/server.py +++ b/whisper_live/server.py @@ -300,11 +300,15 @@ class TranscriptionServer: host (str): The host address to bind the server. port (int): The port number to bind the server. """ + if faster_whisper_custom_model_path is not None and not os.path.exists(faster_whisper_custom_model_path): + raise ValueError(f"Custom faster_whisper model '{faster_whisper_custom_model_path}' is not a valid path.") + if whisper_tensorrt_path is not None and not os.path.exists(whisper_tensorrt_path): + raise ValueError(f"TensorRT model '{whisper_tensorrt_path}' is not a valid path.") if single_model: if faster_whisper_custom_model_path or whisper_tensorrt_path: logging.info("Custom model option was provided. Switching to single model mode.") self.single_model = True - # TODO: load models initially + # TODO: load model initially else: logging.info("Single model mode currently only works with custom models.") with serve(