Prefer whisper small model for offline STT

This commit is contained in:
Stu Leak 2026-01-11 07:12:36 -05:00
parent 0d32018e71
commit 77853ca4f2
2 changed files with 17 additions and 8 deletions

View File

@ -344,18 +344,18 @@ else
# Whisper backend is offline-only; no auto-install here.
fi
# Seed whisper.cpp model from bundled offline assets (base model)
whisper_model_src="$(cd "$(dirname "$0")/.." && pwd)/vendor/whisper/ggml-base.bin"
# Seed whisper.cpp model from bundled offline assets (small model)
whisper_model_src="$(cd "$(dirname "$0")/.." && pwd)/vendor/whisper/ggml-small.bin"
whisper_model_dir="$HOME/.local/share/whisper.cpp/models"
if [ -f "$whisper_model_src" ]; then
mkdir -p "$whisper_model_dir"
if [ ! -f "$whisper_model_dir/ggml-base.bin" ]; then
cp "$whisper_model_src" "$whisper_model_dir/ggml-base.bin"
echo -e "${GREEN}[OK]${NC} Whisper base model installed to $whisper_model_dir"
if [ ! -f "$whisper_model_dir/ggml-small.bin" ]; then
cp "$whisper_model_src" "$whisper_model_dir/ggml-small.bin"
echo -e "${GREEN}[OK]${NC} Whisper small model installed to $whisper_model_dir"
fi
else
echo -e "${RED}[ERROR]${NC} Offline Whisper model not found at vendor/whisper/ggml-base.bin"
echo "Place ggml-base.bin there to keep installs fully offline."
echo -e "${RED}[ERROR]${NC} Offline Whisper model not found at vendor/whisper/ggml-small.bin"
echo "Place ggml-small.bin there to keep installs fully offline."
exit 1
fi

View File

@ -1021,15 +1021,18 @@ func detectWhisperBackend() string {
func detectWhisperModel() string {
preferred := []string{
filepath.Join("models", "ggml-base.bin"),
filepath.Join("models", "ggml-small.bin"),
filepath.Join("models", "ggml-base.bin"),
filepath.Join("models", "ggml-medium.bin"),
filepath.Join("models", "ggml-large.bin"),
filepath.Join("vendor", "whisper", "ggml-small.bin"),
filepath.Join("vendor", "whisper", "ggml-base.bin"),
}
if exe, err := os.Executable(); err == nil {
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, "models", "ggml-small.bin"))
preferred = append(preferred, filepath.Join(dir, "models", "ggml-base.bin"))
}
for _, candidate := range preferred {
@ -1058,6 +1061,12 @@ func detectWhisperModel() string {
if len(matches) == 0 {
continue
}
for _, match := range matches {
base := filepath.Base(match)
if base == "ggml-small.bin" {
return match
}
}
for _, match := range matches {
base := filepath.Base(match)
if base == "ggml-base.bin" {