Skip to content

Fix OpenRouter MAI-Voice speech playback - #16463

Merged
danielhanchen merged 2 commits into
mainfrom
fix/openrouter-mai-tts-16443
Nov 2, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fix/openrouter-mai-tts-16443

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Studio requests WAV for external speech, but OpenRouter's Microsoft MAI-Voice models accept only MP3 or PCM. Preview and read-aloud therefore fail with HTTP 400. Request PCM for this provider/model family when WAV is requested, then wrap the unchanged 24 kHz mono 16-bit samples as WAV for Studio's existing playback and WAV-only backend consumers.

The adaptation is limited to OpenRouter MAI-Voice WAV requests. Explicit MP3/PCM requests and other providers/models retain their behavior. No UI controls, dependencies, model weights, or device routing change. This does not add OpenRouter models to the Audio workspace picker.

Validation at d9690f5:

  • A real loopback HTTP server rejects WAV and accepts PCM, following the OpenRouter TTS contract and PCM encoding specification.
  • Base/head differential: 4 tests fail without the fix and pass with it; 8 controls pass on both sides. Checks cover WAV metadata, exact sample bytes, repeat requests, provider isolation, and explicit formats.
  • Broader external-provider and speech suite: 166 passed. Formatter, Ruff, symbol audit, and pre-push checks pass.
  • Scoped staging on Windows, macOS Apple Silicon, and Linux: 12 tests on each OS.
  • A 90-cell provider/model/format comparison changes only the three intended MAI WAV requests; 87 other cells stay identical. The resulting WAV bytes match an independent reference.
  • Follow-up review reproduced rejection of valid Audio/PCM; the comparison now follows HTTP's case-insensitive media-type rules.

Broader validation limits: the initial Studio switchboard reported functional NO_REGRESSION, with settings coverage gaps from an initially blank page and crawl visual differences outside the speech path. Its model journeys ran remotely on Colab T4 High-RAM. The broader staging parity job was inconclusive because its base-versus-base control marked all 32 action pairs unstable and compared zero stable pairs. These results are not being presented as complete UI parity. The final-head switchboard is CURRENT and reports functional NO_REGRESSION: 48 SAME, one FLAKY, one retained VISUAL_DIFF, one DOM_ONLY_DIFF; coverage 87.5% overall and 95.5% safe. The primary hub confirmation images are pixel-identical, while an extra image-viewer capture differs in its magenta mask bounds. Its visual classification is retained, so full visual parity remains unproven. The DOM-only Studio difference has zero changed pixels.

Live paid-provider synthesis, voice quality, and Windows Desktop audio playback have not been exercised. The fix covers the reported MAI-Voice family; generic format negotiation for other TTS providers/models remains separate work.

Fixes #16443

Settings > Voice preview, exact merge base versus d9690f5 in two isolated installs. Both use the reported model and German voice. A local HTTP fixture enforces OpenRouter's documented formats and returns a test tone: before, WAV is rejected with HTTP 400; after, PCM is returned as WAV and Chromium emits its native playing event, with Stop visible. This demonstrates Studio integration and playback, not live OpenRouter synthesis or voice quality.

MAI-Voice preview before and after

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 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-11-02T08:03:15.636775Z d9690f5 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. What shall we delve into next?

Reviewed commit: b19cf38a87

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: d9690f57f2

ℹ️ 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".

@danielhanchen
danielhanchen merged commit 49aef9f into main Nov 2, 2026
@danielhanchen
danielhanchen deleted the fix/openrouter-mai-tts-16443 branch November 2, 2026 08:37
danielhanchen added a commit that referenced this pull request Nov 2, 2026
…#16464)

## Summary

`Parity verdict, scored against the null` fails on unrelated PRs whose
base includes #16300 (`d56738f404`, the turn navigator at the chat's
left edge). In the last two hours it failed on #16458 (a backend-only
change) and on staging for #16463 and #16435, each time the same way:

```
matched:                    0
unstable actions differing: 32  (expected to vary; not a verdict)
NOTHING WAS COMPARED. ... This is not a pass.
```

In the null control (the same build on both arms), every action's thread
scaffold digest differs, even between two repetitions on the same arm,
while its length stays equal (`thread scaffolding outside any message
(24167->24167c)`). That is an instance id leaking into the structural
signature.

#16300 renders the navigator inside the thread root, outside every
message, as one button per turn with `data-turn-id={openerId}`.
`openerId` is the turn's opening message id (`thread-turns.ts` pushes
`message.id`). `scene/parity.js` already drops the values of
`data-message-id`, `data-thread-id` and the other id attributes it knew
about, but not this new one. Studio's message ids are short and random,
so `ID_RE` does not catch them in the value either.

The product is fine; the instrument fell behind the DOM.

## Change

- **`tests/studio/studiobench/scene/parity.js`:** an attribute is
volatile if it is in `VOLATILE_ATTRS`, or if its name matches
`data-*-id`. A volatile attribute keeps its presence in the signature
and loses only its value, as before.
- Every `data-*-id` in the frontend names an instance, e.g.
`data-turn-id`, `data-queue-item-id`, `data-bookmark-id`,
`data-entry-id`.
- So the next one added inside the thread cannot silently empty the
verdict the way this one did.
- Non-id data attributes (`data-turn`, `data-role`, `data-state`, ...)
still compare by value.
-
**`tests/studio/studiobench/fixture/selftest/test_studiobench_parity_digest.py`**
(these run the shipped `parity.js` under node):
- `test_every_data_id_attribute_is_volatile`: two different
`data-turn-id` values sign the same, a button with the attribute still
differs from one without it, and the same holds for
`data-queue-item-id`.
- `test_a_data_attribute_that_is_not_an_id_still_moves_the_signature`:
`data-turn="1"` against `"2"` still differs.

## Testing

- `tests/studio/studiobench/fixture/selftest`, `sweep/selftest` and
`analysis/selftest`: 606 passed.
- Sabotage: with main's `parity.js`,
`test_every_data_id_attribute_is_volatile` fails; the other new test
passes on both.
- Not proven here: I did not rerun the full parity sweep locally. The
PR's own parity job is the end-to-end check. On main's harness it should
report a non-zero `matched` count on this PR, as the runs before #16300
did (28 or 29).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] (fix included!) External text-to-speech fails when using OpenRouter / expects wav instead of mp3/pcm.

1 participant