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/packages/core/src/__tests__/e2e/stt-integration.test.ts

overstepping7b10591a4ebe
diff --git a/xspace-agent/xspace-agent/packages/core/src/__tests__/e2e/stt-integration.test.ts b/xspace-agent/xspace-agent/packages/core/src/__tests__/e2e/stt-integration.test.ts
new file mode 100644
index 000000000..c8a3967dd
--- /dev/null
+++ b/xspace-agent/xspace-agent/packages/core/src/__tests__/e2e/stt-integration.test.ts
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§87]
+
+import { describe, it, expect } from 'vitest'
+import fs from 'fs'
+import path from 'path'
+import { createSTT } from '../../pipeline/stt'
+
+const hasOpenAI = !!process.env.OPENAI_API_KEY
+const hasGroq = !!process.env.GROQ_API_KEY
+
+const fixturesDir = path.join(__dirname, '..', 'fixtures')
+const helloWav = fs.existsSync(path.join(fixturesDir, 'hello.wav'))
+ ? fs.readFileSync(path.join(fixturesDir, 'hello.wav'))
+ : null
+const silenceWav = fs.existsSync(path.join(fixturesDir, 'silence.wav'))
+ ? fs.readFileSync(path.join(fixturesDir, 'silence.wav'))
+ : null
+
+describe.skipIf(!hasOpenAI)('OpenAI STT E2E', () => {
+ const stt = createSTT({
+ provider: 'openai',
+ apiKey: process.env.OPENAI_API_KEY!,
+ })
+
+ it('should transcribe audio from a WAV file', async () => {
+ expect(helloWav).not.toBeNull()
+ const result = await stt.transcribe(helloWav!, 'audio/wav')
+
+ expect(result).toBeDefined()
+ expect(typeof result.text).toBe('string')
+ // The synthetic tone may or may not produce meaningful text,
+ // but the API should return a valid response
+ expect(result).toHaveProperty('text')
+ }, 30_000)
+
+ it('should handle silence gracefully', async () => {
+ expect(silenceWav).not.toBeNull()
+ const result = await stt.transcribe(silenceWav!, 'audio/wav')
+
+ expect(result).toBeDefined()
+ expect(typeof result.text).toBe('string')
+ // Silence should produce empty or very short transcription
+ expect(result.text.length).toBeLessThan(50)
+ }, 30_000)
+})
+
+describe.skipIf(!hasGroq)('Groq STT E2E', () => {
+ const stt = createSTT({
+ provider: 'groq',
+ apiKey: process.env.GROQ_API_KEY!,
+ })
+
+ it('should transcribe audio from a WAV file', async () => {
+ expect(helloWav).not.toBeNull()
+ const result = await stt.transcribe(helloWav!, 'audio/wav')
+
+ expect(result).toBeDefined()
+ expect(typeof result.text).toBe('string')
+ expect(result).toHaveProperty('text')
+ }, 30_000)
+
+ it('should handle silence gracefully', async () => {
+ expect(silenceWav).not.toBeNull()
+ const result = await stt.transcribe(silenceWav!, 'audio/wav')
+
+ expect(result).toBeDefined()
+ expect(typeof result.text).toBe('string')
+ expect(result.text.length).toBeLessThan(50)
+ }, 30_000)
+})
+
+