fix(openai): mark mp3 TTS voice output compatible#83227
Conversation
|
Codex review: needs changes before merge. Reviewed July 1, 2026, 1:58 AM ET / 05:58 UTC. Summary PR surface: Source +7, Tests +39. Total +46 across 3 files. Reproducibility: yes. from source inspection rather than a live run. Current main still returns voiceCompatible=false for configured OpenAI MP3 voice-note synthesis, while speech-core and Telegram already use the voice path when that flag is true. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land or replace the provider-boundary fix on current main, using shared media compatibility and keeping the speech-core regression under packages/speech-core. Do we have a high-confidence way to reproduce the issue? Yes, from source inspection rather than a live run. Current main still returns voiceCompatible=false for configured OpenAI MP3 voice-note synthesis, while speech-core and Telegram already use the voice path when that flag is true. Is this the best way to solve the issue? Yes for the provider-boundary shape, but not for the current branch state. Reusing the shared media helper is the narrow fix; the branch still needs a rebase or replacement and the speech-core test must move to the current package path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2c7e989686ba. Label changesLabel justifications:
Evidence reviewedPR surface: Source +7, Tests +39. Total +46 across 3 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
e8aa071 to
04a13bc
Compare
04a13bc to
d67894a
Compare
d67894a to
b7d0f62
Compare
|
@clawsweeper re-review Rebased onto latest |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
b7d0f62 to
46953d2
Compare
46953d2 to
7d6773b
Compare
|
Landed the cleaned-up fix in 9302c80 via #100715. The maintained version uses the shared voice-message compatibility helper, keeps WAV on the audio-file path, adds focused WAV/MP3 regression coverage, and preserves your contributor credit. I recreated it because this fork branch was not editable by maintainers and had conflicts with current Thank you, @HemantSudarshan. Enabling Allow edits by maintainers on future pull requests lets us update the original branch directly. |
Fixes #80317.
Summary
responseFormat: "mp3".Problem summary
The OpenAI speech provider only marked voice-note synthesis as voice-compatible when
responseFormat === "opus". That made OpenAI-compatible local TTS servers configured for MP3 produce an audio file result even though the shared media contract and Telegram send path already allow MP3 voice delivery.Root cause
extensions/openai/speech-provider.tsused a provider-local equality check foropus, while the rest of the TTS/channel path usesisVoiceCompatibleAudio()to decide whether a produced audio asset can be delivered as a voice note. Microsoft/Edge TTS already follows that shared helper path for MP3 output, so OpenAI-compatible MP3 output diverged from the existing runtime contract.Architectural reasoning
This keeps the behavior at the provider boundary: the OpenAI provider still reports compatibility only for a
voice-notesynthesis target, but it now asks the shared media runtime whether the selected container extension is voice-compatible. The change does not alter provider selection, gateway/session flow, async cleanup, request timing, or Telegram transport behavior. It only corrects the metadata emitted by OpenAI-compatible synthesis results so the existing speech-core and Telegram delivery contracts can do what they already support.Testing performed
Local proof on refreshed head
7d6773b18c4679697f5ca65c9d1fa7b1ac382b5b:pnpm test extensions/openai/speech-provider.test.ts extensions/speech-core/src/tts.test.ts -- --reporter=verbosepassed: OpenAI provider 10/10, speech-core 28/28.pnpm test extensions/telegram/src/send.test.ts -- --reporter=verbose -t "routes audio media to sendAudio/sendVoice based on voice compatibility"passed: 1/1 selected, 102 skipped.buildOpenAISpeechProvider()capturedPOST /v1/audio/speechwithresponse_format: "mp3"; the returned result wasoutputFormat: "mp3",fileExtension: ".mp3", andvoiceCompatible: true.pnpm format:check -- extensions/openai/speech-provider.ts extensions/openai/speech-provider.test.ts extensions/speech-core/src/tts.test.tspnpm check:changedgit diff --check upstream/main..HEADGitHub Actions on
7d6773b18c4679697f5ca65c9d1fa7b1ac382b5b:Real behavior proof
Behavior addressed: OpenAI-compatible TTS configured with
responseFormat: "mp3"should mark voice-note synthesis output as voice-compatible so Telegram delivery can use the voice path instead of falling back to audio-file delivery.Real environment tested: Local Windows checkout on branch
Hemant/fix-openai-tts-mp3-voice, Nodev22.15.0with the repository's existing engine warning. The branch was rebased onto upstream/main6baa2b38b2712384d7de460d90b127cd78dbb3a5; upstream moved tobc4f27c89a3c5aa40b7fb9e507a91b6e6c753307while checks ran, and GitHub reported the PR mergeable against the live base after push. The extra proof used the production OpenAI speech provider against a real local HTTP OpenAI-compatible speech endpoint with redacted auth.Exact steps or command run after this patch: Started a local HTTP server, invoked
buildOpenAISpeechProvider().synthesize()withbaseUrlpointed at that server,responseFormat: "mp3", andtarget: "voice-note", then captured the outbound OpenAI-compatible request and provider result.Evidence after fix:
{ "capturedRequest": { "method": "POST", "url": "/v1/audio/speech", "responseFormat": "mp3", "model": "local-compatible-tts", "voice": "alloy" }, "outputFormat": "mp3", "fileExtension": ".mp3", "voiceCompatible": true, "audioBytes": 6 }Observed result after fix: The production provider requests MP3 from the OpenAI-compatible speech endpoint and returns MP3 voice-note synthesis as voice-compatible. The speech-core regression keeps that provider-compatible MP3 result on Telegram voice delivery, and the Telegram send regression confirms compatible MP3 voice delivery maps to
sendVoice.What was not tested: I did not send a live Telegram message or call a credentialed third-party OpenAI-compatible TTS server. The local HTTP proof exercises the same production provider request/result path without secrets.
Risk analysis
Backward compatibility
Backward compatible. Users who explicitly configured
responseFormat: "mp3"for OpenAI-compatible TTS now get the expected voice-compatible metadata for voice-note targets. Non-voice targets and formats that are not accepted by the shared media helper keep their previous fallback behavior.