Prefer whisper small model for offline STT
This commit is contained in:
parent
0d32018e71
commit
77853ca4f2
|
|
@ -344,18 +344,18 @@ else
|
||||||
# Whisper backend is offline-only; no auto-install here.
|
# Whisper backend is offline-only; no auto-install here.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Seed whisper.cpp model from bundled offline assets (base model)
|
# Seed whisper.cpp model from bundled offline assets (small model)
|
||||||
whisper_model_src="$(cd "$(dirname "$0")/.." && pwd)/vendor/whisper/ggml-base.bin"
|
whisper_model_src="$(cd "$(dirname "$0")/.." && pwd)/vendor/whisper/ggml-small.bin"
|
||||||
whisper_model_dir="$HOME/.local/share/whisper.cpp/models"
|
whisper_model_dir="$HOME/.local/share/whisper.cpp/models"
|
||||||
if [ -f "$whisper_model_src" ]; then
|
if [ -f "$whisper_model_src" ]; then
|
||||||
mkdir -p "$whisper_model_dir"
|
mkdir -p "$whisper_model_dir"
|
||||||
if [ ! -f "$whisper_model_dir/ggml-base.bin" ]; then
|
if [ ! -f "$whisper_model_dir/ggml-small.bin" ]; then
|
||||||
cp "$whisper_model_src" "$whisper_model_dir/ggml-base.bin"
|
cp "$whisper_model_src" "$whisper_model_dir/ggml-small.bin"
|
||||||
echo -e "${GREEN}[OK]${NC} Whisper base model installed to $whisper_model_dir"
|
echo -e "${GREEN}[OK]${NC} Whisper small model installed to $whisper_model_dir"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${RED}[ERROR]${NC} Offline Whisper model not found at vendor/whisper/ggml-base.bin"
|
echo -e "${RED}[ERROR]${NC} Offline Whisper model not found at vendor/whisper/ggml-small.bin"
|
||||||
echo "Place ggml-base.bin there to keep installs fully offline."
|
echo "Place ggml-small.bin there to keep installs fully offline."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1021,15 +1021,18 @@ func detectWhisperBackend() string {
|
||||||
|
|
||||||
func detectWhisperModel() string {
|
func detectWhisperModel() string {
|
||||||
preferred := []string{
|
preferred := []string{
|
||||||
filepath.Join("models", "ggml-base.bin"),
|
|
||||||
filepath.Join("models", "ggml-small.bin"),
|
filepath.Join("models", "ggml-small.bin"),
|
||||||
|
filepath.Join("models", "ggml-base.bin"),
|
||||||
filepath.Join("models", "ggml-medium.bin"),
|
filepath.Join("models", "ggml-medium.bin"),
|
||||||
filepath.Join("models", "ggml-large.bin"),
|
filepath.Join("models", "ggml-large.bin"),
|
||||||
|
filepath.Join("vendor", "whisper", "ggml-small.bin"),
|
||||||
filepath.Join("vendor", "whisper", "ggml-base.bin"),
|
filepath.Join("vendor", "whisper", "ggml-base.bin"),
|
||||||
}
|
}
|
||||||
if exe, err := os.Executable(); err == nil {
|
if exe, err := os.Executable(); err == nil {
|
||||||
dir := filepath.Dir(exe)
|
dir := filepath.Dir(exe)
|
||||||
|
preferred = append(preferred, filepath.Join(dir, "vendor", "whisper", "ggml-small.bin"))
|
||||||
preferred = append(preferred, filepath.Join(dir, "vendor", "whisper", "ggml-base.bin"))
|
preferred = append(preferred, filepath.Join(dir, "vendor", "whisper", "ggml-base.bin"))
|
||||||
|
preferred = append(preferred, filepath.Join(dir, "models", "ggml-small.bin"))
|
||||||
preferred = append(preferred, filepath.Join(dir, "models", "ggml-base.bin"))
|
preferred = append(preferred, filepath.Join(dir, "models", "ggml-base.bin"))
|
||||||
}
|
}
|
||||||
for _, candidate := range preferred {
|
for _, candidate := range preferred {
|
||||||
|
|
@ -1058,6 +1061,12 @@ func detectWhisperModel() string {
|
||||||
if len(matches) == 0 {
|
if len(matches) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
for _, match := range matches {
|
||||||
|
base := filepath.Base(match)
|
||||||
|
if base == "ggml-small.bin" {
|
||||||
|
return match
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, match := range matches {
|
for _, match := range matches {
|
||||||
base := filepath.Base(match)
|
base := filepath.Base(match)
|
||||||
if base == "ggml-base.bin" {
|
if base == "ggml-base.bin" {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user