error on unsupported language instead of silent fallback

This commit is contained in:
leonardotrapani
2026-02-02 10:33:50 +01:00
parent d62e7b14e4
commit b0bb41707d
+1 -5
View File
@@ -3,7 +3,6 @@ package transcriber
import ( import (
"context" "context"
"fmt" "fmt"
"log"
"golang.org/x/text/cases" "golang.org/x/text/cases"
"golang.org/x/text/language" "golang.org/x/text/language"
@@ -76,11 +75,8 @@ func NewTranscriber(config Config) (Transcriber, error) {
return nil, fmt.Errorf("model %s is not a transcription model", config.Model) return nil, fmt.Errorf("model %s is not a transcription model", config.Model)
} }
// runtime language-model compatibility check with fallback
// primary validation happens at config time (hard error), this is a safety net
if config.Language != "" && !model.SupportsLanguage(config.Language) { if config.Language != "" && !model.SupportsLanguage(config.Language) {
log.Printf("warning: model %s does not support language %s, falling back to auto-detect", model.ID, config.Language) return nil, fmt.Errorf("model %s does not support language %s", model.ID, config.Language)
config.Language = ""
} }
// validate streaming/batch mode compatibility // validate streaming/batch mode compatibility