From 500b84caec582b5f99aa0432af3a20014dcb280d Mon Sep 17 00:00:00 2001 From: leonardotrapani Date: Sun, 1 Feb 2026 22:15:30 +0100 Subject: [PATCH] fix: tests in ci --- README.md | 1 + internal/transcriber/adapter_whisper_cpp.go | 10 ++++---- .../transcriber/adapter_whisper_cpp_test.go | 24 +++++++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 58d07f7..86aebb4 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Press a toggle key, speak, and get instant text input. Built natively for Waylan - Toggle workflow with optional status notifications and cancel support. - Text injection via ydotool, wtype, and clipboard fallback with clipboard restore. - Guided onboarding and a full configure menu with hot-reload. +- Personalization through custom prompt and keywords sent both to LLM and to voice model. ## Voice Providers and Models diff --git a/internal/transcriber/adapter_whisper_cpp.go b/internal/transcriber/adapter_whisper_cpp.go index d32196e..661a6af 100644 --- a/internal/transcriber/adapter_whisper_cpp.go +++ b/internal/transcriber/adapter_whisper_cpp.go @@ -36,17 +36,17 @@ func (a *WhisperCppAdapter) Transcribe(ctx context.Context, audioData []byte) (s return "", nil } + // check model file exists + if _, err := os.Stat(a.modelPath); os.IsNotExist(err) { + return "", fmt.Errorf("model file not found: %s", a.modelPath) + } + // check whisper-cli exists whisperPath, err := exec.LookPath("whisper-cli") if err != nil { return "", fmt.Errorf("whisper-cli not found: install whisper.cpp first") } - // check model file exists - if _, err := os.Stat(a.modelPath); os.IsNotExist(err) { - return "", fmt.Errorf("model file not found: %s", a.modelPath) - } - // convert raw PCM to WAV wavData, err := convertToWAV(audioData) if err != nil { diff --git a/internal/transcriber/adapter_whisper_cpp_test.go b/internal/transcriber/adapter_whisper_cpp_test.go index e870d69..a3671ae 100644 --- a/internal/transcriber/adapter_whisper_cpp_test.go +++ b/internal/transcriber/adapter_whisper_cpp_test.go @@ -3,6 +3,7 @@ package transcriber import ( "context" "os" + "os/exec" "path/filepath" "testing" ) @@ -38,6 +39,29 @@ func TestWhisperCppAdapter_MissingModel(t *testing.T) { } } +func TestWhisperCppAdapter_MissingCli(t *testing.T) { + if _, err := exec.LookPath("whisper-cli"); err == nil { + t.Skip("whisper-cli is installed") + } + + tmpDir := t.TempDir() + modelPath := filepath.Join(tmpDir, "model.bin") + if err := os.WriteFile(modelPath, []byte("fake"), 0600); err != nil { + t.Fatalf("failed to create model: %v", err) + } + + adapter := NewWhisperCppAdapter(modelPath, "en", 4) + audioData := make([]byte, 32000) + + _, err := adapter.Transcribe(context.Background(), audioData) + if err == nil { + t.Error("expected error for missing whisper-cli") + } + if err != nil && !contains(err.Error(), "whisper-cli not found") { + t.Errorf("expected 'whisper-cli not found' error, got: %v", err) + } +} + func TestWhisperCppAdapter_LanguageConversion(t *testing.T) { // verify adapter stores language for later conversion adapter := NewWhisperCppAdapter("/fake/model.bin", "", 4)