From 0fdb55d317d5e27f8d0ebc8650a848b37013615f Mon Sep 17 00:00:00 2001 From: Roque Giordano <43444235+RoqueGio@users.noreply.github.com> Date: Wed, 1 Jan 2025 09:16:45 -0300 Subject: [PATCH] feat: add local_files_only option on whisperx.load_model for offline mode (#867) Adds the parameter local_files_only (default False for consistency) to whisperx.load_model so that the user can avoid downloading the file and return the path to the local cached file if it exists. --------- Co-authored-by: Barabazs <31799121+Barabazs@users.noreply.github.com> --- whisperx/asr.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/whisperx/asr.py b/whisperx/asr.py index 07e5115..0ea03b6 100644 --- a/whisperx/asr.py +++ b/whisperx/asr.py @@ -269,6 +269,7 @@ def load_model(whisper_arch, model : Optional[WhisperModel] = None, task="transcribe", download_root=None, + local_files_only=False, threads=4): '''Load a Whisper model for inference. Args: @@ -279,6 +280,7 @@ def load_model(whisper_arch, language: str - The language of the model. (use English for now) model: Optional[WhisperModel] - The WhisperModel instance to use. download_root: Optional[str] - The root directory to download the model to. + local_files_only: bool - If `True`, avoid downloading the file and return the path to the local cached file if it exists. threads: int - The number of cpu threads to use per worker, e.g. will be multiplied by num workers. Returns: A Whisper pipeline. @@ -292,6 +294,7 @@ def load_model(whisper_arch, device_index=device_index, compute_type=compute_type, download_root=download_root, + local_files_only=local_files_only, cpu_threads=threads) if language is not None: tokenizer = faster_whisper.tokenizer.Tokenizer(model.hf_tokenizer, model.model.is_multilingual, task=task, language=language)