44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
// Copyright (c) 2026 Storm Dragon
|
|
// Authors: Storm Dragon, Angus Kola
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package speech
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestDiscoverVoicesAndOutputModule(t *testing.T) {
|
|
path, server := newSettingsServer(t, func(command string) string {
|
|
switch command {
|
|
case "LIST OUTPUT_MODULES":
|
|
return "200-test\r\n200 OK\r\n"
|
|
case "LIST SYNTHESIS_VOICES":
|
|
return "200-Test Voice\ten-US\tnone\r\n200 OK\r\n"
|
|
}
|
|
return ""
|
|
})
|
|
catalog, err := Discover(context.Background(), path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, module := range []string{"", "test"} {
|
|
voices := catalog[module]
|
|
if len(voices) != 1 || voices[0].Name != "Test Voice" || voices[0].Language != "en-US" {
|
|
t.Fatalf("catalog=%+v", catalog)
|
|
}
|
|
}
|
|
if !server.saw(1, "SET SELF OUTPUT_MODULE test") {
|
|
t.Fatal("did not select module for discovery")
|
|
}
|
|
client := NewWithSettings(path, Settings{OutputModule: "test", SynthesisVoice: "Test Voice"})
|
|
defer client.Close(context.Background())
|
|
if err := client.Connect(context.Background()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !server.saw(2, "SET SELF OUTPUT_MODULE test") || !server.saw(2, "SET SELF SYNTHESIS_VOICE Test Voice") {
|
|
t.Fatal("echo voice/module not configured")
|
|
}
|
|
}
|