Peter commited on
Commit
78726ec
·
unverified ·
1 Parent(s): be8fe47

whisper : update default model download directory behavior to use current working directory when script is in /bin/ directory (#2924)

Browse files

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 CHANGED
@@ -19,7 +19,15 @@ get_script_path() {
19
  fi
20
  }
21
 
22
- models_path="$(get_script_path)"
 
 
 
 
 
 
 
 
23
 
24
  # Whisper models
25
  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() {
34
  printf "\n\n"
35
  }
36
 
37
- if [ "$#" -ne 1 ]; then
38
- printf "Usage: %s <model>\n" "$0"
39
  list_models
40
 
41
  exit 1
 
19
  fi
20
  }
21
 
22
+ script_path="$(get_script_path)"
23
+
24
+ # Check if the script is inside a /bin/ directory
25
+ case "$script_path" in
26
+ */bin) default_download_path="$PWD" ;; # Use current directory as default download path if in /bin/
27
+ *) default_download_path="$script_path" ;; # Otherwise, use script directory
28
+ esac
29
+
30
+ models_path="${2:-$default_download_path}"
31
 
32
  # Whisper models
33
  models="tiny.en tiny base.en base small.en small medium.en medium large-v1 large-v2 large-v3 large-v3-turbo"
 
42
  printf "\n\n"
43
  }
44
 
45
+ if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
46
+ printf "Usage: %s <model> [models_path]\n" "$0"
47
  list_models
48
 
49
  exit 1
models/download-ggml-model.sh CHANGED
@@ -22,7 +22,15 @@ get_script_path() {
22
  fi
23
  }
24
 
25
- models_path="${2:-$(get_script_path)}"
 
 
 
 
 
 
 
 
26
 
27
  # Whisper models
28
  models="tiny
 
22
  fi
23
  }
24
 
25
+ script_path="$(get_script_path)"
26
+
27
+ # Check if the script is inside a /bin/ directory
28
+ case "$script_path" in
29
+ */bin) default_download_path="$PWD" ;; # Use current directory as default download path if in /bin/
30
+ *) default_download_path="$script_path" ;; # Otherwise, use script directory
31
+ esac
32
+
33
+ models_path="${2:-$default_download_path}"
34
 
35
  # Whisper models
36
  models="tiny