feat: better language selection

This commit is contained in:
leonardotrapani
2026-02-01 18:53:44 +01:00
parent 0025bf97b6
commit 3ae86f7bae
40 changed files with 452 additions and 852 deletions
+6 -5
View File
@@ -10,8 +10,6 @@ import (
"path/filepath"
"strings"
"time"
"github.com/leonardotrapani/hyprvoice/internal/language"
)
// WhisperCppAdapter implements BatchAdapter for local whisper-cpp transcription
@@ -23,7 +21,7 @@ type WhisperCppAdapter struct {
// NewWhisperCppAdapter creates a new whisper-cpp adapter
// modelPath: full path to the model file (e.g., ~/.local/share/hyprvoice/models/whisper/ggml-base.en.bin)
// lang: canonical language code (will be converted to whisper-cpp format)
// lang: whisper-cpp language code
// threads: number of CPU threads (0 for auto)
func NewWhisperCppAdapter(modelPath, lang string, threads int) *WhisperCppAdapter {
return &WhisperCppAdapter{
@@ -63,8 +61,11 @@ func (a *WhisperCppAdapter) Transcribe(ctx context.Context, audioData []byte) (s
}
defer os.Remove(tmpFile)
// convert language to whisper-cpp format
lang := language.ToProviderFormat(a.language, "whisper-cpp")
// use whisper-cpp auto if unspecified
lang := a.language
if lang == "" {
lang = "auto"
}
// build command args
args := []string{