
























@@ -85,6 +85,15 @@ async function withAcmeSpeechProvider(
8585);
8686}
878788+function expectSingleSynthesizeSpeechCall() {
89+expect(synthesizeSpeechMock).toHaveBeenCalledTimes(1);
90+const params = synthesizeSpeechMock.mock.calls[0]?.[0];
91+if (params === undefined) {
92+throw new Error("expected synthesizeSpeech call params");
93+}
94+return params;
95+}
96+8897describe("gateway talk runtime", () => {
8998beforeEach(() => {
9099synthesizeSpeechMock.mockReset();
@@ -125,26 +134,23 @@ describe("gateway talk runtime", () => {
125134text: "Hello from talk mode.",
126135});
127136expect(res?.ok, JSON.stringify(res?.error)).toBe(true);
128-expect(synthesizeSpeechMock).toHaveBeenCalledWith(
129-expect.objectContaining({
130-text: "Hello from talk mode.",
131-overrides: { provider: "acme" },
132-disableFallback: true,
133-cfg: expect.objectContaining({
134-messages: expect.objectContaining({
135-tts: expect.objectContaining({
136-provider: "acme",
137-providers: expect.objectContaining({
138-acme: expect.objectContaining({
139-resolvedBy: "acme-test-provider",
140-voiceId: "plugin-voice",
141-}),
142-}),
143-}),
144-}),
145-}),
146-}),
147-);
137+const synthesizeParams = expectSingleSynthesizeSpeechCall();
138+expect(synthesizeParams.text).toBe("Hello from talk mode.");
139+expect(synthesizeParams.overrides).toEqual({ provider: "acme" });
140+expect(synthesizeParams.disableFallback).toBe(true);
141+const ttsConfig = (
142+synthesizeParams.cfg as {
143+messages?: {
144+tts?: {
145+provider?: string;
146+providers?: Record<string, { resolvedBy?: string; voiceId?: string }>;
147+};
148+};
149+}
150+).messages?.tts;
151+expect(ttsConfig?.provider).toBe("acme");
152+expect(ttsConfig?.providers?.acme?.resolvedBy).toBe("acme-test-provider");
153+expect(ttsConfig?.providers?.acme?.voiceId).toBe("plugin-voice");
148154},
149155);
150156});
@@ -224,22 +230,19 @@ describe("gateway talk runtime", () => {
224230expect((res?.payload as TalkSpeakTestPayload | undefined)?.audioBase64).toBe(
225231Buffer.from([4, 5, 6]).toString("base64"),
226232);
227-expect(synthesizeSpeechMock).toHaveBeenCalledWith(
228-expect.objectContaining({
229-text: "Hello from talk mode.",
230-overrides: {
231-provider: "elevenlabs",
232-providerOverrides: {
233-elevenlabs: {
234-voiceId: ALIAS_STUB_VOICE_ID,
235-outputFormat: "pcm_44100",
236-latencyTier: 3,
237-},
238-},
233+const synthesizeParams = expectSingleSynthesizeSpeechCall();
234+expect(synthesizeParams.text).toBe("Hello from talk mode.");
235+expect(synthesizeParams.overrides).toEqual({
236+provider: "elevenlabs",
237+providerOverrides: {
238+elevenlabs: {
239+voiceId: ALIAS_STUB_VOICE_ID,
240+outputFormat: "pcm_44100",
241+latencyTier: 3,
239242},
240- disableFallback: true,
241- }),
242-);
243+},
244+});
245+expect(synthesizeParams.disableFallback).toBe(true);
243246},
244247);
245248});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。