]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
whisper : update default model download directory behavior to use current working...
authorPeter <redacted>
Sat, 22 Mar 2025 14:27:57 +0000 (01:27 +1100)
committerGitHub <redacted>
Sat, 22 Mar 2025 14:27:57 +0000 (16:27 +0200)
This change ensures that when the script is packaged and distributed, models are downloaded to the current directory instead of the script's location, preventing conflicts with system directories. This improves flexibility and usability for distribution and packaging scenarios.

models/download-coreml-model.sh
models/download-ggml-model.sh

index 3d80ee7d2aea9e3b843f52a0436a138c9e846748..3088c29ab2adf258933282dc9d79c30b32e4a088 100755 (executable)
@@ -19,7 +19,15 @@ get_script_path() {
     fi
 }
 
-models_path="$(get_script_path)"
+script_path="$(get_script_path)"
+
+# Check if the script is inside a /bin/ directory
+case "$script_path" in
+    */bin) default_download_path="$PWD" ;;  # Use current directory as default download path if in /bin/
+    *) default_download_path="$script_path" ;;  # Otherwise, use script directory
+esac
+
+models_path="${2:-$default_download_path}"
 
 # Whisper models
 models="tiny.en tiny base.en base small.en small medium.en medium large-v1 large-v2 large-v3 large-v3-turbo"
@@ -34,8 +42,8 @@ list_models() {
         printf "\n\n"
 }
 
-if [ "$#" -ne 1 ]; then
-    printf "Usage: %s <model>\n" "$0"
+if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
+    printf "Usage: %s <model> [models_path]\n" "$0"
     list_models
 
     exit 1
index a1aff210780094962dd7c6172c0b6603d93a6889..5832fd21ef40eb7dd604dfdc21c0d9f3081bedef 100755 (executable)
@@ -22,7 +22,15 @@ get_script_path() {
     fi
 }
 
-models_path="${2:-$(get_script_path)}"
+script_path="$(get_script_path)"
+
+# Check if the script is inside a /bin/ directory
+case "$script_path" in
+    */bin) default_download_path="$PWD" ;;  # Use current directory as default download path if in /bin/
+    *) default_download_path="$script_path" ;;  # Otherwise, use script directory
+esac
+
+models_path="${2:-$default_download_path}"
 
 # Whisper models
 models="tiny