Debian Codegraph @

generate/whispercpp/convert-pt-to-ggml.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 # generate/whispercpp/convert-pt-to-ggml.sh
4 # Anastasia Shchupak, 16 March 2026
5 #
6 # Shell script that clones OpenAI Whisper repository, downloads an original OpenAI Whisper PyTorch model,
7 # and converts it to GGML binary format, using the Python script convert-pt-to-ggml.py.
8 #
9 # Usage: convert-pt-to-ggml.sh <whisper-model-name>
10 # Example: convert-pt-to-ggml.sh tiny
11
12 set -e # stop if any command fails
13
14 # OpenAI Whisper models available for conversion
15 models="tiny tiny.en base base.en small small.en medium medium.en large-v1 large-v2 large-v3 large-v3-turbo"
16
17 list_modelsscip-shell shell shell-project 0.0.0 list_models().() {
18 printfscip-shell system . . printf. "\nAvailable models:\n "
19 for model in $models; do
20 printfscip-shell system . . printf. " %s" "$model"
21 done
22 printfscip-shell system . . printf. "\n\n"
23 printfscip-shell system . . printf. ".en = english-only\n\n"
24 }
25
26 # check if a model name is provided
27 if [scip-shell system . . `[`. -z "$1" ]; then
28 printfscip-shell system . . printf. "Usage: %s <whisper-model-name>\n" "$0"
29 printfscip-shell system . . printf. "Example: %s tiny\n" "$0"
30 list_modelsscip-shell shell shell-project 0.0.0 list_models().
31 exit 1
32 fi
33
34 MODEL_NAME="$1"
35
36 # validate model name
37 if ! echoscip-shell system . . echo. "$models" | trscip-shell system . . tr. ' ' '\n' | grepscip-shell system . . grep. -qx "$MODEL_NAME"; then
38 printfscip-shell system . . printf. "Invalid model: %s\n" "$MODEL_NAME"
39 list_modelsscip-shell shell shell-project 0.0.0 list_models().
40 exit 1
41 fi
42
43 echoscip-shell system . . echo. "Creating virtual environment..."
44 python3scip-shell system . . python3. -m venv venv
45
46 echoscip-shell system . . echo. "Activating virtual environment..."
47 source venv/bin/activatescip-shell source . . `venv/bin/activate`.
48
49 if [scip-shell system . . `[`. -d "whisper" ]; then
50 echoscip-shell system . . echo. "OpenAI whisper repository already cloned, skipping."
51 else
52 echoscip-shell system . . echo. "Cloning OpenAI whisper repository..."
53 gitscip-shell system . . git. clone https://github.com/openai/whisper
54 fi
55
56 echoscip-shell system . . echo. "Installing openai-whisper and dependencies..."
57 pipscip-shell system . . pip. install openai-whisper
58
59 echoscip-shell system . . echo. "Downloading original PyTorch model..."
60 python3scip-shell system . . python3. -c "import whisper; whisper.load_model('${MODEL_NAME}', download_root='./')"
61
62 echoscip-shell system . . echo. "Converting Whisper model to GGML format..."
63 python3scip-shell system . . python3. convert-pt-to-ggml.py ./"${MODEL_NAME}".pt ./whisper/ ./
64
65 echoscip-shell system . . echo. "Deactivating virtual environment..."
66 deactivate
67
68 mvscip-shell system . . mv. ggml-model.bin ggml-"${MODEL_NAME}".bin
69
70 echoscip-shell system . . echo. "Done. Whisper model '${MODEL_NAME}' is downloaded and converted to GGML binary format."