From a09ce6e8899198015729ffc49ae10f67370906b1 Mon Sep 17 00:00:00 2001 From: andypayne Date: Tue, 25 Oct 2022 17:35:11 -0700 Subject: [PATCH] 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. --- models/download-ggml-model.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/models/download-ggml-model.sh b/models/download-ggml-model.sh index 8caaeda..10a15c9 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"