Spaces:
Running
Running
jefffffff9 Claude Sonnet 4.6 commited on
Commit ·
bcc9a12
1
Parent(s): ca322f7
Add setup.sh to pre-cache Whisper model during build
Browse filesHF Spaces caches the build layer, so downloading during setup.sh
avoids re-downloading the model on every cold start.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
setup.sh
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs during HF Spaces build phase (build layer is cached).
|
| 3 |
+
# Pre-downloads the Whisper model so cold starts don't re-download it.
|
| 4 |
+
# WHISPER_MODEL_ID is available as an env var at build time if set in Space secrets.
|
| 5 |
+
MODEL=${WHISPER_MODEL_ID:-openai/whisper-small}
|
| 6 |
+
echo "Pre-caching $MODEL ..."
|
| 7 |
+
python -c "
|
| 8 |
+
from huggingface_hub import snapshot_download
|
| 9 |
+
import os
|
| 10 |
+
snapshot_download('${MODEL}', repo_type='model')
|
| 11 |
+
print('Done.')
|
| 12 |
+
"
|