feat: switch audio and storage providers to qwen3 tts and minio

This commit is contained in:
Codex
2026-02-18 13:58:23 +00:00
parent 31e8e07319
commit 445e5725b3
6 changed files with 273 additions and 258 deletions

View File

@@ -4,29 +4,48 @@ const test = require("node:test");
const assert = require("node:assert/strict");
const { createTTSAdapter } = require("../src/integrations/tts-client");
test("synthesize returns buffer from openai response", async () => {
test("synthesize returns buffer from qwen-compatible audio endpoint", async () => {
const calls = [];
const adapter = createTTSAdapter({
client: {
audio: {
speech: {
async create() {
return {
async arrayBuffer() {
return Uint8Array.from([1, 2, 3]).buffer;
},
};
},
apiKey: "qwen-key",
baseURL: "https://qwen.example/v1",
fetchImpl: async (url, init) => {
calls.push({ url, init });
return {
ok: true,
status: 200,
async arrayBuffer() {
return Uint8Array.from([1, 2, 3]).buffer;
},
},
};
},
});
const bytes = await adapter.synthesize("hello");
assert.equal(Buffer.isBuffer(bytes), true);
assert.equal(bytes.length, 3);
assert.equal(calls.length, 1);
assert.equal(calls[0].url, "https://qwen.example/v1/audio/speech");
assert.match(String(calls[0].init.headers.authorization), /^Bearer qwen-key$/);
assert.match(String(calls[0].init.body), /"model":"qwen-tts-latest"/);
});
test("throws when tts adapter is not configured", async () => {
const adapter = createTTSAdapter({});
await assert.rejects(() => adapter.synthesize("hello"), /tts_not_configured/);
});
test("throws with upstream status code when synthesis fails", async () => {
const adapter = createTTSAdapter({
apiKey: "qwen-key",
fetchImpl: async () => ({
ok: false,
status: 401,
async arrayBuffer() {
return new ArrayBuffer(0);
},
}),
});
await assert.rejects(() => adapter.synthesize("hello"), /tts_request_failed:401/);
});