From 2d7c984bfc67d4f848f8b2844d2650f6028d9618 Mon Sep 17 00:00:00 2001 From: Guillaume Klein Date: Thu, 11 May 2023 14:47:22 +0200 Subject: [PATCH] Reformat function download_model for clarity --- faster_whisper/utils.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/faster_whisper/utils.py b/faster_whisper/utils.py index bf274aa..94a203f 100644 --- a/faster_whisper/utils.py +++ b/faster_whisper/utils.py @@ -62,14 +62,6 @@ def download_model( ) repo_id = "guillaumekln/faster-whisper-%s" % size - kwargs = {} - kwargs["local_files_only"] = local_files_only - if output_dir is not None: - kwargs["local_dir"] = output_dir - kwargs["local_dir_use_symlinks"] = False - - if cache_dir is not None: - kwargs["cache_dir"] = cache_dir allow_patterns = [ "config.json", @@ -77,8 +69,19 @@ def download_model( "tokenizer.json", "vocabulary.txt", ] - kwargs["allow_patterns"] = allow_patterns - kwargs["tqdm_class"] = disabled_tqdm + + kwargs = { + "local_files_only": local_files_only, + "allow_patterns": allow_patterns, + "tqdm_class": disabled_tqdm, + } + + if output_dir is not None: + kwargs["local_dir"] = output_dir + kwargs["local_dir_use_symlinks"] = False + + if cache_dir is not None: + kwargs["cache_dir"] = cache_dir try: return huggingface_hub.snapshot_download(