From: andypayne Date: Wed, 26 Oct 2022 00:35:11 +0000 (-0700) Subject: Changes to work by default on macOS - use curl when wget is not available, and use... X-Git-Tag: upstream/1.7.4~1897 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=a09ce6e8899198015729ffc49ae10f67370906b1;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp Changes to work by default on macOS - use curl when wget is not available, and use an alternative method to get the script path when realpath is not available. --- diff --git a/models/download-ggml-model.sh b/models/download-ggml-model.sh index 8caaeda9..10a15c95 100755 --- a/models/download-ggml-model.sh +++ b/models/download-ggml-model.sh @@ -3,7 +3,17 @@ # This script downloads Whisper model files that have already been converted to ggml format. # This way you don't have to convert them yourself. -models_path=$(dirname $(realpath $0)) +# get the path of this script +function get_script_path() { + if [ -x "$(command -v realpath)" ]; then + echo "$(dirname $(realpath $0))" + else + local ret="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" + echo "$ret" + fi +} + +models_path=$(get_script_path) # Whisper models models=( "tiny.en" "tiny" "base.en" "base" "small.en" "small" "medium.en" "medium" "large" ) @@ -45,7 +55,15 @@ if [ -f "ggml-$model.bin" ]; then exit 0 fi -wget --quiet --show-progress -O ggml-$model.bin https://ggml.ggerganov.com/ggml-model-whisper-$model.bin +if [ -x "$(command -v wget)" ]; then + wget --quiet --show-progress -O ggml-$model.bin https://ggml.ggerganov.com/ggml-model-whisper-$model.bin +elif [ -x "$(command -v curl)" ]; then + curl --output ggml-$model.bin https://ggml.ggerganov.com/ggml-model-whisper-$model.bin +else + printf "Either wget or curl is required to download models.\n" + exit 1 +fi + if [ $? -ne 0 ]; then printf "Failed to download ggml model $model \n"