| | |
| | | } |
| | | } |
| | | |
| | | func TestRegistryReturnsCantoneseSenseVoiceYueDefault(t *testing.T) { |
| | | languageProfile, err := GetLanguageProfile(CantoneseLanguageID) |
| | | if err != nil { |
| | | t.Fatal(err) |
| | | } |
| | | if languageProfile.NativeName != "粤语" { |
| | | t.Fatalf("Cantonese native name = %q, want 粤语", languageProfile.NativeName) |
| | | } |
| | | if languageProfile.DefaultModelID != SenseVoiceYueModelID { |
| | | t.Fatalf("Cantonese default model = %q, want %q", languageProfile.DefaultModelID, SenseVoiceYueModelID) |
| | | } |
| | | if len(languageProfile.UpgradeModelIDs) != 0 { |
| | | t.Fatalf("Cantonese upgrade models = %v, want none", languageProfile.UpgradeModelIDs) |
| | | } |
| | | |
| | | profile, err := GetModelProfile(SenseVoiceYueModelID) |
| | | if err != nil { |
| | | t.Fatal(err) |
| | | } |
| | | if profile.BackendKind != BackendSenseVoice { |
| | | t.Fatalf("backend kind = %q, want %q", profile.BackendKind, BackendSenseVoice) |
| | | } |
| | | if profile.LanguageParam != "yue" { |
| | | t.Fatalf("language param = %q, want yue", profile.LanguageParam) |
| | | } |
| | | if profile.InstallDirName != "sensevoice-yue-2025-09-09" { |
| | | t.Fatalf("install dir = %q, want sensevoice-yue-2025-09-09", profile.InstallDirName) |
| | | } |
| | | if !stringSliceContains(profile.SupportedLanguageIDs, CantoneseLanguageID) { |
| | | t.Fatalf("supported languages = %v, want %s", profile.SupportedLanguageIDs, CantoneseLanguageID) |
| | | } |
| | | if len(profile.DownloadURLs) == 0 { |
| | | t.Fatal("expected SenseVoice Yue download URL") |
| | | } |
| | | } |
| | | |
| | | func TestRegistryReturnsQwen3ASRChinese(t *testing.T) { |
| | | profile, err := GetModelProfile(Qwen3ASRModelID) |
| | | if err != nil { |
| | |
| | | } |
| | | } |
| | | |
| | | func TestLanguageProfileOrderPlacesCantoneseAfterChinese(t *testing.T) { |
| | | profiles := ListLanguageProfiles() |
| | | if len(profiles) < 3 { |
| | | t.Fatalf("language profiles len = %d, want at least 3", len(profiles)) |
| | | } |
| | | if profiles[0].ID != DefaultLanguageID { |
| | | t.Fatalf("first language = %q, want %q", profiles[0].ID, DefaultLanguageID) |
| | | } |
| | | if profiles[1].ID != CantoneseLanguageID { |
| | | t.Fatalf("second language = %q, want %q", profiles[1].ID, CantoneseLanguageID) |
| | | } |
| | | if profiles[2].ID != EnglishLanguageID { |
| | | t.Fatalf("third language = %q, want %q", profiles[2].ID, EnglishLanguageID) |
| | | } |
| | | } |
| | | |
| | | func TestNormalizeLanguageIDAcceptsCantoneseAlias(t *testing.T) { |
| | | if got := NormalizeLanguageID("yue"); got != CantoneseLanguageID { |
| | | t.Fatalf("NormalizeLanguageID(yue) = %q, want %q", got, CantoneseLanguageID) |
| | | } |
| | | if got := NormalizeLanguageID(CantoneseLanguageID); got != CantoneseLanguageID { |
| | | t.Fatalf("NormalizeLanguageID(%s) = %q", CantoneseLanguageID, got) |
| | | } |
| | | } |
| | | |
| | | func TestValidateSenseVoiceAnyOfAndAllOf(t *testing.T) { |
| | | dir := t.TempDir() |
| | | writeTestFile(t, filepath.Join(dir, "tokens.txt"), "tokens") |
| | |
| | | } |
| | | } |
| | | |
| | | func TestValidateSenseVoiceYueRequiredFiles(t *testing.T) { |
| | | profile, err := GetModelProfile(SenseVoiceYueModelID) |
| | | if err != nil { |
| | | t.Fatal(err) |
| | | } |
| | | dir := t.TempDir() |
| | | createValidSenseVoice(t, dir) |
| | | |
| | | result := ValidateModelDir(profile, dir) |
| | | if !result.Valid { |
| | | t.Fatalf("expected valid SenseVoice Yue dir, missing=%v problems=%v", result.Missing, result.Problems) |
| | | } |
| | | if got := filepath.Base(result.Files["model"]); got != "model.int8.onnx" { |
| | | t.Fatalf("model file = %q, want model.int8.onnx", got) |
| | | } |
| | | if result.Files["tokens"] == "" { |
| | | t.Fatal("missing resolved tokens file") |
| | | } |
| | | } |
| | | |
| | | func TestValidateSenseVoiceYueRejectsFp32OnlyModel(t *testing.T) { |
| | | profile, err := GetModelProfile(SenseVoiceYueModelID) |
| | | if err != nil { |
| | | t.Fatal(err) |
| | | } |
| | | dir := t.TempDir() |
| | | writeTestFile(t, filepath.Join(dir, "tokens.txt"), "tokens") |
| | | writeTestFile(t, filepath.Join(dir, "model.onnx"), "fp32") |
| | | |
| | | result := ValidateModelDir(profile, dir) |
| | | if result.Valid { |
| | | t.Fatal("expected SenseVoice Yue to require model.int8.onnx") |
| | | } |
| | | } |
| | | |
| | | func TestValidateMoonshineRequiredFiles(t *testing.T) { |
| | | profile, err := GetModelProfile(MoonshineModelID) |
| | | if err != nil { |