Skip to content

fix(studio): repair custom TTS endpoint test and playback - #9905

Merged
Etherll merged 5 commits into
unslothai:mainfrom
Souravrajvi0:feat/tts-custom-endpoint-fix-b930
Aug 29, 2026
Merged

Etherll merged 5 commits into
unslothai:mainfrom
Souravrajvi0:feat/tts-custom-endpoint-fix-b930

Conversation

@Souravrajvi0

@Souravrajvi0 Souravrajvi0 commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9895

Problem

Custom connection tests always probed /chat/completions, which fails for TTS-only OpenAI-compatible gateways like Kokoro FastAPI that expose /v1/models and /v1/audio/speech but not chat completions.

TTS preview/read-aloud could return HTTP 200 yet fail to play in the browser with "The fetching process for the media resource was aborted by the user agent at the user's request." Kokoro defaults to stream: true, and blob URLs were created without preserving the upstream Content-Type.

Fix

  1. Connection test — probe endpoints in order: /models → /audio/speech → /chat/completions.
  2. External TTS proxy — send stream: false so upstream servers return a complete audio file instead of a chunked stream.
  3. Frontend playback — build blob URLs using the response Content-Type header.

Testing

  • Added/updated backend tests for the new connection-test probe order and stream: false on create_speech.
  • Updated frontend TTS custom-connection tests for the blob MIME handling.
  • pytest tests/test_external_provider_usage_chunk.py tests/test_openai_audio_speech_route.py — 72 passed
  • node --test tests/tts-custom-connections-disabled.test.ts — 11 passed

Custom connection tests always probed /chat/completions, which fails for
TTS-only gateways like Kokoro that expose /models and /audio/speech.
Probe /models first, then /audio/speech, then chat completions.

When proxying speech to external providers, send stream=false so servers
that default to chunked streaming return a complete audio file. Preserve
the upstream Content-Type when creating browser blob URLs so playback
does not abort on undecodable media.
@danielhanchen

Copy link
Copy Markdown
Member

Confirmed the custom provider test in studio/backend/routes/providers.py still probes only /chat/completions and that the blob URL in studio-speech-synthesis-adapter.ts drops the upstream content type, so both halves of this match what I see on main. One thing to double check before review: sending stream: false unconditionally from create_speech for every provider, not just gateways that default to streaming.

@Souravrajvi0

Copy link
Copy Markdown
Contributor Author

Thanks for checking, @danielhanchen.

On this branch (893aa3956 / 6a8c17d), all three items are addressed:

  1. Custom provider test — _test_custom_provider_connectivity() in studio/backend/routes/providers.py now probes /models first, then /audio/speech via create_speech, and only falls back to /chat/completions if both fail. Covered by test_custom_provider_test_falls_back_to_speech_for_tts_only_gateways.

  2. Blob playback content type — generateCustomTtsAudio() in studio-speech-synthesis-adapter.ts reads the upstream Content-Type header and passes it into new Blob([bytes], { type: contentType }) instead of response.blob().

  3. stream: false unconditionally — ExternalProviderClient.create_speech() always sends "stream": false in the JSON body (no provider-type branching). Both call sites (provider test probe and /audio/speech proxy in inference.py) go through this method. Asserted in test_openai_audio_speech_route.py.

If anything still looks like main on your side, could you share which commit SHA you're viewing? Happy to walk through the diff.

@Etherll Etherll self-assigned this Aug 28, 2026
@Etherll

Etherll commented Aug 29, 2026 •

Copy link
Copy Markdown
Collaborator

NOT READY.

The conflict is resolved against current main. The approved merge is live at 912289e6, GitHub reports the PR as mergeable, and there was no force-push or upstream merge.

The merged head is clean on the reviewed scope: three exact-head review lanes closed 55/55 obligations with zero findings. Validation passed 75 speech/provider tests, 55 transcription tests, the saved-credential guard, 11 frontend authority/adapter tests, py_compile, diff checks, the conflict validator, and a full-net safety scan. The one additional red singleton guard reproduces on exact main.

Fresh UI A/B proof is bound to base c5b23438 and head 912289e6. With the same saved connection and two three-second WAV segments, BEFORE returned to Preview after the first RIFF container; AFTER produced one valid 96,044-byte WAV and still showed Stop at 3.75 seconds.

PR 9905 before and after TTS preview

The conflict blocker is resolved. Readiness is still blocked because the replacement required CI run has 45 nonterminal checks; it must reach a required-green terminal state before this can be called ready.

Resolve the speech-route test conflict by preserving main's instructions assertion and strict JSON access alongside the PR's no-stream, WAV merge, and cancellation coverage.
@Etherll

Etherll commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-29T01:45:02.036244Z 912289e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 912289e6eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Etherll Etherll left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@Etherll
Etherll merged commit aa2b914 into unslothai:main Aug 29, 2026
41 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] TTS custom endpoint failures

3 participants