diff --git a/internal/transcriber/transcriber.go b/internal/transcriber/transcriber.go index fae093b..56a9783 100644 --- a/internal/transcriber/transcriber.go +++ b/internal/transcriber/transcriber.go @@ -5,6 +5,7 @@ import ( "fmt" "strings" + "github.com/leonardotrapani/hyprvoice/internal/models/whisper" "github.com/leonardotrapani/hyprvoice/internal/provider" "github.com/leonardotrapani/hyprvoice/internal/recording" ) @@ -106,6 +107,12 @@ func NewTranscriber(config Config) (Transcriber, error) { adapter = NewOpenAIAdapter(model.Endpoint, config.APIKey, model.ID, config.Language, config.Keywords, registryProvider) case "elevenlabs": adapter = NewElevenLabsAdapter(model.Endpoint, config.APIKey, model.ID, config.Language) + case "whisper-cpp": + modelPath := whisper.GetModelPath(config.Model) + if modelPath == "" { + return nil, fmt.Errorf("unknown whisper model: %s", config.Model) + } + adapter = NewWhisperCppAdapter(modelPath, config.Language, config.Threads) default: return nil, fmt.Errorf("unsupported adapter type: %s", model.AdapterType) } diff --git a/internal/transcriber/transcriber_test.go b/internal/transcriber/transcriber_test.go index d0613c4..bac667a 100644 --- a/internal/transcriber/transcriber_test.go +++ b/internal/transcriber/transcriber_test.go @@ -174,6 +174,35 @@ func TestNewTranscriber(t *testing.T) { }, wantErr: true, }, + { + name: "valid whisper-cpp config creates adapter", + config: Config{ + Provider: "whisper-cpp", + Language: "en", + Model: "base.en", + Threads: 4, + }, + wantErr: false, // creates adapter even if model file doesn't exist (runtime check) + }, + { + name: "whisper-cpp without api key is valid", + config: Config{ + Provider: "whisper-cpp", + APIKey: "", // no api key required + Language: "en", + Model: "tiny.en", + }, + wantErr: false, + }, + { + name: "whisper-cpp with unknown model returns error", + config: Config{ + Provider: "whisper-cpp", + Language: "en", + Model: "nonexistent-whisper-model", + }, + wantErr: true, + }, } for _, tt := range tests { diff --git a/progress.txt b/progress.txt index 4356281..fb52672 100644 --- a/progress.txt +++ b/progress.txt @@ -217,4 +217,12 @@ Started: Sun Feb 1 12:22:47 AM CET 2026 - DefaultModel(Transcription) returns 'base.en' - Registered in provider.init() - Comprehensive test file created: whisper_cpp_test.go +- All tests passing, typecheck passes + +### Task 22: Wire whisper-cpp into transcriber factory +- Added `case "whisper-cpp"` to NewTranscriber() switch on model.AdapterType +- Imports whisper package to get model path via `whisper.GetModelPath(config.Model)` +- Creates `NewWhisperCppAdapter(modelPath, config.Language, config.Threads)` +- Returns error if whisper model ID is unknown +- Added tests for whisper-cpp factory cases: valid config, no API key required, unknown model error - All tests passing, typecheck passes \ No newline at end of file diff --git a/tasks/prd.jsonc b/tasks/prd.jsonc index 1bb3b00..c1ea80e 100644 --- a/tasks/prd.jsonc +++ b/tasks/prd.jsonc @@ -530,7 +530,7 @@ "Full flow works: config -> factory -> adapter -> transcription", "Typecheck passes" ], - "passes": false + "passes": true }, { "title": "Update config for local transcription",