

























@@ -81,6 +81,10 @@ async function waitForLiveExpectation(expectation: () => void, timeoutMs = 30_00
8181throw lastError;
8282}
838384+function normalizeTranscriptForMatch(value: string): string {
85+return value.toLowerCase().replace(/[^a-z0-9]+/g, "");
86+}
87+8488describeLive("xai plugin live", () => {
8589it("synthesizes TTS through the registered speech provider", async () => {
8690const { speechProviders } = await registerXaiPlugin();
@@ -155,13 +159,40 @@ describeLive("xai plugin live", () => {
155159});
156160157161const normalized = transcript?.text.toLowerCase() ?? "";
162+const compact = normalizeTranscriptForMatch(normalized);
158163expect(transcript?.model).toBe(XAI_DEFAULT_STT_MODEL);
159-expect(normalized).toContain("openclaw");
164+expect(compact).toContain("openclaw");
160165expect(normalized).toContain("speech");
161166expect(normalized).toContain("text");
162167expect(normalized).toContain("integration");
163168}, 180_000);
164169170+it("opens xAI realtime STT before sending audio", async () => {
171+const { realtimeTranscriptionProviders } = await registerXaiPlugin();
172+const realtimeProvider = requireRegisteredProvider(realtimeTranscriptionProviders, "xai");
173+const errors: Error[] = [];
174+const session = realtimeProvider.createSession({
175+providerConfig: {
176+apiKey: XAI_API_KEY,
177+baseUrl: "https://api.x.ai/v1",
178+sampleRate: 16_000,
179+encoding: "pcm",
180+interimResults: true,
181+endpointingMs: 800,
182+language: "en",
183+},
184+onError: (error) => errors.push(error),
185+});
186+187+try {
188+await session.connect();
189+expect(errors).toEqual([]);
190+expect(session.isConnected()).toBe(true);
191+} finally {
192+session.close();
193+}
194+}, 30_000);
195+165196it("streams realtime STT through the registered transcription provider", async () => {
166197const { realtimeTranscriptionProviders, speechProviders } = await registerXaiPlugin();
167198const realtimeProvider = requireRegisteredProvider(realtimeTranscriptionProviders, "xai");
@@ -216,9 +247,11 @@ describeLive("xai plugin live", () => {
216247if (errors[0]) {
217248throw errors[0];
218249}
219-expect(transcripts.join(" ").toLowerCase()).toContain("openclaw");
250+expect(normalizeTranscriptForMatch(transcripts.join(" "))).toContain("openclaw");
220251}, 60_000);
221252const normalized = transcripts.join(" ").toLowerCase();
253+const compact = normalizeTranscriptForMatch(normalized);
254+expect(compact).toContain("openclaw");
222255expect(normalized).toContain("transcription");
223256expect(partials.length + transcripts.length).toBeGreaterThan(0);
224257}, 180_000);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。