forked from argmaxinc/WhisperKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (44 loc) · 1.42 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
.PHONY: setup download-models build build-cli test
PIP_COMMAND := pip3
PYTHON_COMMAND := python3
# Define model repository and directories
MODEL_REPO := argmaxinc/whisperkit-coreml
MODEL_REPO_DIR := ./Models/whisperkit-coreml
BASE_COMPILED_DIR := ./Models
setup:
@echo "Setting up environment..."
@which $(PIP_COMMAND)
@which $(PYTHON_COMMAND)
@$(PIP_COMMAND) install -U huggingface_hub
@if huggingface-cli whoami; then \
echo "Already logged in to Hugging Face."; \
else \
echo "Not logged in to Hugging Face."; \
if [ -z "$$HF_TOKEN" ]; then \
echo "Environment variable HF_TOKEN is not set. Running normal login."; \
huggingface-cli login; \
else \
echo "Using HF_TOKEN from environment variable."; \
huggingface-cli login --token $$HF_TOKEN; \
fi; \
fi
download-models:
@echo "Downloading compressed models..."
@mkdir -p $(BASE_COMPILED_DIR)
@if [ -d "$(MODEL_REPO_DIR)/.git" ]; then \
echo "Repository exists, pulling latest changes..."; \
cd $(MODEL_REPO_DIR) && git reset --hard origin/main; \
else \
echo "Repository not found, cloning..."; \
$(eval HF_USERNAME := $(shell huggingface-cli whoami | head -n 1)) \
git clone https://$(HF_USERNAME):$(HF_TOKEN)@hf.co/$(MODEL_REPO) $(MODEL_REPO_DIR); \
fi
build:
@echo "Building WhisperKit..."
@swift build -v
build-cli:
@echo "Building WhisperKit CLI..."
@swift build -c release --product transcribe
test:
@echo "Running tests..."
@swift test -v