Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

add xspace-agent/xspace-agent/agent-voice-chat/tests/e2e/providers/openai-tts.e2e.test.js

overstepping3f059f5151fc
diff --git a/xspace-agent/xspace-agent/agent-voice-chat/tests/e2e/providers/openai-tts.e2e.test.js b/xspace-agent/xspace-agent/agent-voice-chat/tests/e2e/providers/openai-tts.e2e.test.js
new file mode 100644
index 000000000..9626c596a
--- /dev/null
+++ b/xspace-agent/xspace-agent/agent-voice-chat/tests/e2e/providers/openai-tts.e2e.test.js
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent)
+
+import { describe, it, expect } from "vitest"
+import { describeProvider, measureLatency } from "../setup.js"
+
+describeProvider("openai-tts", () => {
+ it("should synthesize speech with OpenAI TTS", async () => {
+ // Import the real TTS module — it reads OPENAI_API_KEY from env
+ const axios = (await import("axios")).default
+
+ const { result: audioBuffer, latencyMs } = await measureLatency(async () => {
+ const response = await axios.post(
+ "https://api.openai.com/v1/audio/speech",
+ {
+ model: "tts-1",
+ input: "Hello, this is an end-to-end test.",
+ voice: "alloy",
+ response_format: "mp3",
+ },
+ {
+ headers: {
+ Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
+ "Content-Type": "application/json",
+ },
+ responseType: "arraybuffer",
+ }
+ )
+ return Buffer.from(response.data)
+ })
+
+ expect(audioBuffer).toBeInstanceOf(Buffer)
+ expect(audioBuffer.length).toBeGreaterThan(100) // MP3 should have meaningful size
+ expect(latencyMs).toBeLessThan(30000)
+
+ console.log(`[E2E] OpenAI TTS: ${audioBuffer.length} bytes (${latencyMs}ms)`)
+ })
+
+ it("should synthesize with different voices", async () => {
+ const axios = (await import("axios")).default
+ const voices = ["alloy", "nova"]
+ const results = []
+
+ for (const voice of voices) {
+ const response = await axios.post(
+ "https://api.openai.com/v1/audio/speech",
+ {
+ model: "tts-1",
+ input: "Test.",
+ voice,
+ response_format: "mp3",
+ },
+ {
+ headers: {
+ Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
+ "Content-Type": "application/json",
+ },
+ responseType: "arraybuffer",
+ }
+ )
+ results.push({ voice, size: response.data.byteLength })
+ }
+
+ for (const r of results) {
+ expect(r.size).toBeGreaterThan(100)
+ console.log(`[E2E] OpenAI TTS voice "${r.voice}": ${r.size} bytes`)
+ }
+ })
+})
+
+