2022-09-26 08:36:51 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script downloads Whisper model files that have already been converted to ggml format.
|
|
|
|
# This way you don't have to convert them yourself.
|
|
|
|
|
2022-11-15 18:47:06 +01:00
|
|
|
#src="https://ggml.ggerganov.com"
|
|
|
|
#pfx="ggml-model-whisper"
|
|
|
|
|
2023-03-22 19:44:56 +01:00
|
|
|
src="https://huggingface.co/ggerganov/whisper.cpp"
|
2022-11-15 18:47:06 +01:00
|
|
|
pfx="resolve/main/ggml"
|
|
|
|
|
2022-10-26 02:35:11 +02:00
|
|
|
# get the path of this script
|
|
|
|
function get_script_path() {
|
|
|
|
if [ -x "$(command -v realpath)" ]; then
|
2023-03-29 22:38:33 +02:00
|
|
|
echo "$(dirname "$(realpath "$0")")"
|
2022-10-26 02:35:11 +02:00
|
|
|
else
|
|
|
|
local ret="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
|
|
|
|
echo "$ret"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-12-22 12:16:02 +01:00
|
|
|
models_path="${2:-$(get_script_path)}"
|
2022-09-26 08:36:51 +02:00
|
|
|
|
|
|
|
# Whisper models
|
2023-11-15 18:42:25 +01:00
|
|
|
models=(
|
2023-09-07 11:16:58 +02:00
|
|
|
"tiny.en"
|
|
|
|
"tiny"
|
|
|
|
"tiny-q5_1"
|
|
|
|
"tiny.en-q5_1"
|
|
|
|
"base.en"
|
|
|
|
"base"
|
|
|
|
"base-q5_1"
|
|
|
|
"base.en-q5_1"
|
|
|
|
"small.en"
|
|
|
|
"small.en-tdrz"
|
|
|
|
"small"
|
|
|
|
"small-q5_1"
|
|
|
|
"small.en-q5_1"
|
|
|
|
"medium"
|
|
|
|
"medium.en"
|
|
|
|
"medium-q5_0"
|
|
|
|
"medium.en-q5_0"
|
|
|
|
"large-v1"
|
2023-11-07 14:30:18 +01:00
|
|
|
"large-v2"
|
2023-11-15 18:42:25 +01:00
|
|
|
"large-v3"
|
2023-12-29 10:14:32 +01:00
|
|
|
"large-v3-q5_0"
|
2023-09-07 11:16:58 +02:00
|
|
|
)
|
2022-09-26 08:36:51 +02:00
|
|
|
|
|
|
|
# list available models
|
|
|
|
function list_models {
|
|
|
|
printf "\n"
|
|
|
|
printf " Available models:"
|
|
|
|
for model in "${models[@]}"; do
|
|
|
|
printf " $model"
|
|
|
|
done
|
|
|
|
printf "\n\n"
|
|
|
|
}
|
|
|
|
|
2023-12-22 12:16:02 +01:00
|
|
|
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
|
|
|
|
printf "Usage: $0 <model> [models_path]\n"
|
2022-09-26 08:36:51 +02:00
|
|
|
list_models
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
model=$1
|
|
|
|
|
|
|
|
if [[ ! " ${models[@]} " =~ " ${model} " ]]; then
|
|
|
|
printf "Invalid model: $model\n"
|
|
|
|
list_models
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-07-04 08:45:00 +02:00
|
|
|
# check if model contains `tdrz` and update the src and pfx accordingly
|
|
|
|
if [[ $model == *"tdrz"* ]]; then
|
|
|
|
src="https://huggingface.co/akashmjn/tinydiarize-whisper.cpp"
|
|
|
|
pfx="resolve/main/ggml"
|
|
|
|
fi
|
|
|
|
|
2022-09-26 08:36:51 +02:00
|
|
|
# download ggml model
|
|
|
|
|
2022-11-15 18:47:06 +01:00
|
|
|
printf "Downloading ggml model $model from '$src' ...\n"
|
2022-09-26 08:36:51 +02:00
|
|
|
|
2023-06-25 14:22:49 +02:00
|
|
|
cd "$models_path"
|
2022-09-26 08:36:51 +02:00
|
|
|
|
2022-10-25 18:13:08 +02:00
|
|
|
if [ -f "ggml-$model.bin" ]; then
|
2022-09-26 08:36:51 +02:00
|
|
|
printf "Model $model already exists. Skipping download.\n"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2022-10-26 02:35:11 +02:00
|
|
|
if [ -x "$(command -v wget)" ]; then
|
2023-05-08 19:58:36 +02:00
|
|
|
wget --no-config --quiet --show-progress -O ggml-$model.bin $src/$pfx-$model.bin
|
2022-10-26 02:35:11 +02:00
|
|
|
elif [ -x "$(command -v curl)" ]; then
|
2022-11-16 17:53:01 +01:00
|
|
|
curl -L --output ggml-$model.bin $src/$pfx-$model.bin
|
2022-10-26 02:35:11 +02:00
|
|
|
else
|
|
|
|
printf "Either wget or curl is required to download models.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-09-26 08:36:51 +02:00
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
printf "Failed to download ggml model $model \n"
|
|
|
|
printf "Please try again later or download the original Whisper model files and convert them yourself.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-12-22 12:16:02 +01:00
|
|
|
printf "Done! Model '$model' saved in '$models_path/ggml-$model.bin'\n"
|
2022-09-26 08:36:51 +02:00
|
|
|
printf "You can now use it like this:\n\n"
|
2023-12-22 12:16:02 +01:00
|
|
|
printf " $ ./main -m $models_path/ggml-$model.bin -f samples/jfk.wav\n"
|
2022-09-26 08:36:51 +02:00
|
|
|
printf "\n"
|