liuyang commited on
Commit
3ea9b86
·
1 Parent(s): 28a7e7e

Add model downloading functionality for Faster Whisper in app.py, enabling efficient local caching and improved model loading performance.

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -48,6 +48,20 @@ try:
48
  except OSError as e:
49
  sys.exit(f"❌ Could not load {cnn_so} : {e}")
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  # Lazy global holder ----------------------------------------------------------
52
  _whisper = None
53
  _diarizer = None
@@ -77,7 +91,7 @@ def _load_models():
77
  if _whisper is None:
78
  print("Loading Whisper model...")
79
  _whisper = WhisperModel(
80
- "large-v3-turbo",
81
  device="cuda",
82
  compute_type="float16",
83
  )
 
48
  except OSError as e:
49
  sys.exit(f"❌ Could not load {cnn_so} : {e}")
50
 
51
+
52
+ from huggingface_hub import snapshot_download
53
+ MODEL_REPO = "deepdml/faster-whisper-large-v3-turbo-ct2" # CT2 format
54
+ LOCAL_DIR = f"{CACHE_ROOT}/whisper_turbo"
55
+
56
+ # Download once; later runs are instant
57
+ snapshot_download(
58
+ repo_id=MODEL_REPO,
59
+ local_dir=LOCAL_DIR,
60
+ local_dir_use_symlinks=True, # saves disk space
61
+ resume_download=True
62
+ )
63
+ model_cache_path = LOCAL_DIR # <‑‑ this is what we pass to WhisperModel
64
+
65
  # Lazy global holder ----------------------------------------------------------
66
  _whisper = None
67
  _diarizer = None
 
91
  if _whisper is None:
92
  print("Loading Whisper model...")
93
  _whisper = WhisperModel(
94
+ model_cache_path,
95
  device="cuda",
96
  compute_type="float16",
97
  )