2022-09-26 06:36:51 +00: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 17:47:06 +00:00
|
|
|
#src="https://ggml.ggerganov.com"
|
|
|
|
#pfx="ggml-model-whisper"
|
|
|
|
|
2023-03-22 18:44:56 +00:00
|
|
|
src="https://huggingface.co/ggerganov/whisper.cpp"
|
2022-11-15 17:47:06 +00:00
|
|
|
pfx="resolve/main/ggml"
|
|
|
|
|
2022-10-26 00:35:11 +00:00
|
|
|
# get the path of this script
|
|
|
|
function get_script_path() {
|
|
|
|
if [ -x "$(command -v realpath)" ]; then
|
2023-03-29 20:38:33 +00:00
|
|
|
echo "$(dirname "$(realpath "$0")")"
|
2022-10-26 00:35:11 +00:00
|
|
|
else
|
|
|
|
local ret="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
|
|
|
|
echo "$ret"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-12-23 09:11:38 +00:00
|
|
|
models_path="$(get_script_path)"
|
2022-09-26 06:36:51 +00:00
|
|
|
|
|
|
|
# Whisper models
|
2022-12-06 16:48:57 +00:00
|
|
|
models=( "tiny.en" "tiny" "base.en" "base" "small.en" "small" "medium.en" "medium" "large-v1" "large" )
|
2022-09-26 06:36:51 +00:00
|
|
|
|
|
|
|
# list available models
|
|
|
|
function list_models {
|
|
|
|
printf "\n"
|
|
|
|
printf " Available models:"
|
|
|
|
for model in "${models[@]}"; do
|
|
|
|
printf " $model"
|
|
|
|
done
|
|
|
|
printf "\n\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
|
|
printf "Usage: $0 <model>\n"
|
|
|
|
list_models
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
model=$1
|
|
|
|
|
|
|
|
if [[ ! " ${models[@]} " =~ " ${model} " ]]; then
|
|
|
|
printf "Invalid model: $model\n"
|
|
|
|
list_models
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# download ggml model
|
|
|
|
|
2022-11-15 17:47:06 +00:00
|
|
|
printf "Downloading ggml model $model from '$src' ...\n"
|
2022-09-26 06:36:51 +00:00
|
|
|
|
2022-10-25 16:13:08 +00:00
|
|
|
cd $models_path
|
2022-09-26 06:36:51 +00:00
|
|
|
|
2022-10-25 16:13:08 +00:00
|
|
|
if [ -f "ggml-$model.bin" ]; then
|
2022-09-26 06:36:51 +00:00
|
|
|
printf "Model $model already exists. Skipping download.\n"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2022-10-26 00:35:11 +00:00
|
|
|
if [ -x "$(command -v wget)" ]; then
|
2022-11-15 17:47:06 +00:00
|
|
|
wget --quiet --show-progress -O ggml-$model.bin $src/$pfx-$model.bin
|
2022-10-26 00:35:11 +00:00
|
|
|
elif [ -x "$(command -v curl)" ]; then
|
2022-11-16 16:53:01 +00:00
|
|
|
curl -L --output ggml-$model.bin $src/$pfx-$model.bin
|
2022-10-26 00:35:11 +00:00
|
|
|
else
|
|
|
|
printf "Either wget or curl is required to download models.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-09-26 06:36:51 +00: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
|
|
|
|
|
|
|
|
printf "Done! Model '$model' saved in 'models/ggml-$model.bin'\n"
|
|
|
|
printf "You can now use it like this:\n\n"
|
|
|
|
printf " $ ./main -m models/ggml-$model.bin -f samples/jfk.wav\n"
|
|
|
|
printf "\n"
|