OpenAI-compatible speech API adapter #14

Closed
opened 2026-10-25 14:58:39 +00:00 by dsh · 1 comment
Owner

Goal

A cloud engine that works against any OpenAI-compatible /v1/audio/speech endpoint — OpenAI today, and LM Studio / vLLM / LocalAI / Groq / a proxy tomorrow.

Scope

  • fetch(baseURL + '/v1/audio/speech', { method: 'POST', headers: { Authorization, Content-Type }, body: JSON.stringify({ model, input, voice, response_format, speed }) }); response_format: 'wav' (or pcm 24 kHz) preferred over mp3 for latency/gapless.
  • Settings: baseURL (default https://api.openai.com), key, model, voice; model list is free-text + known suggestions, because compatible servers differ.
  • Enforce the 4096-char input cap with the chunker; speed maps to the queue's rate where possible.
  • AbortSignal → abort the fetch; map errors: network/CORS (opaque), 400 (bad request), 401 (bad key — may be unreadable in browser), 429 (rate limit), 5xx (retry once with backoff, never more).
  • No text is sent without an explicit turn action; show the destination host in the UI.
  • Unit tests with a mocked fetch: success, 401 opaque, 429, abort, oversized input.

Acceptance

  • A real reply is spoken through api.openai.com with an operator-provided key, and through a local OpenAI-compatible server with no key configured.
  • Bad key / unreachable server produces an understandable message (or an explicit "provider did not allow reading the error" message), not silence.
  • The adapter survives the 2027-01-06 tts-1 shutdown by configuration alone.

Notes

  • Depends on #8. Part of M2. API facts: docs/research/tts-engines.md §6 (4096 cap, CORS preflight OK, 401 has no ACAO, models deprecated 2027-01-06).
## Goal A cloud engine that works against any OpenAI-compatible `/v1/audio/speech` endpoint — OpenAI today, and LM Studio / vLLM / LocalAI / Groq / a proxy tomorrow. ## Scope - [ ] `fetch(baseURL + '/v1/audio/speech', { method: 'POST', headers: { Authorization, Content-Type }, body: JSON.stringify({ model, input, voice, response_format, speed }) })`; `response_format: 'wav'` (or `pcm` 24 kHz) preferred over mp3 for latency/gapless. - [ ] Settings: baseURL (default `https://api.openai.com`), key, model, voice; model list is free-text + known suggestions, because compatible servers differ. - [ ] Enforce the 4096-char input cap with the chunker; `speed` maps to the queue's rate where possible. - [ ] AbortSignal → abort the fetch; map errors: network/CORS (opaque), 400 (bad request), 401 (bad key — may be unreadable in browser), 429 (rate limit), 5xx (retry once with backoff, never more). - [ ] No text is sent without an explicit turn action; show the destination host in the UI. - [ ] Unit tests with a mocked `fetch`: success, 401 opaque, 429, abort, oversized input. ## Acceptance - A real reply is spoken through `api.openai.com` with an operator-provided key, and through a local OpenAI-compatible server with no key configured. - Bad key / unreachable server produces an understandable message (or an explicit "provider did not allow reading the error" message), not silence. - The adapter survives the 2027-01-06 `tts-1` shutdown by configuration alone. ## Notes - Depends on #8. Part of M2. API facts: `docs/research/tts-engines.md` §6 (4096 cap, CORS preflight OK, 401 has no ACAO, models deprecated 2027-01-06).
Author
Owner

Deferred 2026-10-25 by operator decision (see #22): cloud TTS is out of the initial scope — focus on the JS/WASM voices first. The adapter is not cancelled; the design (OpenAI-compatible, baseURL override, client-side key) stays in docs/dev-plan.md §7.3 and AGENTS.md D8 for when it comes back. Reopen when the local engines are solid.

Related research: tts-1/tts-1-hd/gpt-4o-mini-tts are deprecated and shut down 2027-01-06, so the generic-compatible design is the only durable one.

**Deferred 2026-10-25 by operator decision** (see #22): cloud TTS is out of the initial scope — focus on the JS/WASM voices first. The adapter is not cancelled; the design (OpenAI-compatible, `baseURL` override, client-side key) stays in `docs/dev-plan.md` §7.3 and `AGENTS.md` D8 for when it comes back. Reopen when the local engines are solid. Related research: `tts-1`/`tts-1-hd`/`gpt-4o-mini-tts` are deprecated and shut down 2027-01-06, so the generic-compatible design is the only durable one.
dsh closed this issue 2026-10-25 16:19:59 +00:00
Sign in to join this conversation.
No description provided.