Skip to content

fix(cli): TTS --output writes WAV audio into .mp3 files - #175615

Merged
steipete merged 1 commit into
mainfrom
codex/tts-output-extension
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/tts-output-extension

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw infer tts convert --output speech.mp3 writes WAV data into a .mp3 file when the provider returns WAV (Google does).

User Impact

User impact: TTS output files get an extension that matches the audio actually returned, the same way infer image generate and infer video generate already behave. The JSON path reports the final file. When the requested extension already matches, nothing changes.

Why This Change Was Made

The TTS command copied the provider's audio to the requested path verbatim. It now goes through the shared media output writer that image and video generation already use. That writer sniffs the audio, keeps a matching extension or replaces a mismatched one, and publishes atomically.

Evidence

  • Live, before: a TTS sweep across 7 providers wrote Google's RIFF ... WAVE audio to tts-google.mp3 while the JSON said format: "wav". The other providers returned real MP3.
  • Unit: a new test shows WAV requested as speech.mp3 publishes as speech.wav. The existing atomic-failure test (existing output preserved) was adapted to the shared writer. The full src/cli/capability-cli.test.ts passes (97 tests).
  • Autoreview: scoped-clean at P2.

infer tts convert --output copied the provider audio to the requested
path verbatim, so Google's WAV landed in a .mp3 file. Route it through the
shared media output writer that image and video generation already use,
which keeps a matching extension and replaces a mismatched one.
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 17, 2026 14:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T14:51:12.072015Z 1d5d639 Draft marked ready
ℹ️ 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.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Oct 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d5d639877

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

Comment on lines +119 to +123
const written = await writeOutputAsset({
buffer: await fs.readFile(result.audioPath),
outputPath: params.output,
outputIndex: 0,
outputCount: 1,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Preserve non-sniffable TTS formats when choosing the extension

When DeepInfra or OpenRouter is configured with responseFormat: "pcm" and the user requests an output such as speech.mp3, this call passes neither result.outputFormat nor the .pcm source filename to writeOutputAsset. Raw PCM has no signature that detectMime can sniff, so the shared writer falls back to the requested .mp3 suffix and the original extension/content mismatch remains. Feed the provider format or source-path extension into the output-extension decision so non-self-identifying formats are renamed too.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR routes TTS output through the shared media writer so recognizable audio receives a matching filename extension.

Example: Google returns WAV audio for an invocation requesting --output speech.mp3.

  • Before: WAV bytes are saved as speech.mp3.
  • After: WAV bytes are saved as speech.wav, and the JSON path reports speech.wav.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch appears correct and has meaningful file-output coverage, while supplied after-fix proof remains in-process.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate is exempt for this maintainer-authored PR; supplied evidence covers a pre-fix Google result and an after-fix in-process CLI test with mocked Gateway output, rather than a live after-fix provider run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A requested MP3 filename can contain WAV audio, misleading users and downstream consumers.
Reason: The maintainer-authored direction aligns TTS with the existing generated-media output policy through a small shared-owner change.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes the reported WAV filename mismatch, which remains on current main, without introducing a verified defect.

Priority: P2
Reviewed head: 1d5d6398777dcdaf987983055d90f3886e875e8b

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No after-fix shipped CLI/provider run or recorded base-fail/head-pass execution is supplied for the WAV extension scenario.
Agent review details

How this fits together

The inference CLI receives a provider-generated audio file locally or through a loopback Gateway, publishes the requested output, and returns its path and format.

flowchart LR
  A[Inference CLI] --> B[TTS conversion]
  B --> C[Provider audio file]
  C --> D[Shared media writer]
  D --> E[Atomic file publication]
  E --> F[Output path and JSON result]
Loading

Technical review

Best possible solution:

Use the existing media-output owner to correct recognizable TTS formats while preserving atomic writes and reporting the actual final path.

Do we have a high-confidence way to reproduce the issue?

Current-main source directly establishes the mismatch when WAV audio is copied to speech.mp3; the PR also reports that exact pre-fix provider result, but no target code was executed during this review.

Is this the best way to solve the issue?

Reusing the shared media writer is a focused repair that preserves atomic publication; raw PCM remains a pre-existing limitation outside the stated WAV case.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8cfa2ec42441.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned production change: The introduced diff replaces verbatim atomic copying with writeOutputAsset and returns the writer's final path; atomic publication remains owned by the existing shared writer. (src/cli/capability-cli/tts-runtime.ts:119, 1d5d6398777d)
  • Current main still needs the fix: Current main resolves the requested path and copies the provider file without correcting its extension. (src/cli/capability-cli/tts-runtime.ts:118, 8cfa2ec42441)
  • Focused behavioral coverage: The added CLI test supplies WAV bytes through a mocked Gateway and checks the actual speech.wav bytes, returned path, and absence of speech.mp3; the adapted failure test checks destination preservation and temporary-file cleanup. (src/cli/capability-cli.test.ts:1972, 1d5d6398777d)
  • Earlier PCM comment independently assessed: The existing review comment identifies raw PCM as non-sniffable, which source confirms remains a limitation; the base also copies PCM into any requested suffix, so this is not an introduced regression or a failure of the stated WAV repair. (src/cli/media-output.ts:39, 1d5d6398777d)
  • Prior format repair has a different boundary: fix(tts): avoid mislabeled local and ElevenLabs audio #125628 repaired provider source-format detection and ElevenLabs metadata; it does not replace this CLI output-path correction.
  • Ownership and inspection limits: Feature history identifies Peter Steinberger across the domain split, atomic-output repair, and subsequent TTS refactors. Some historical blob searches failed because promised objects were unavailable; a later GitHub check refresh was blocked by network policy, so complete exact-head CI was not independently established. (src/cli/capability-cli/tts-runtime.ts:121, 8cfa2ec42441)

PR surface

Source +2, Tests +26. Total +28 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 9 7 +2
Tests 1 34 8 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 43 15 +28

Labels

Label changes:

  • add P2: Incorrect TTS filename extensions can confuse playback and downstream processing, with limited impact on the explicit CLI output workflow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Incorrect TTS filename extensions can confuse playback and downstream processing, with limited impact on the explicit CLI output workflow.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Show a shipped CLI conversion receiving Google WAV audio and reporting speech.wav with matching file bytes.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 17, 2026, 11:04 AM ET / 15:04 UTC.

@steipete
steipete merged commit 7fcc86e into main Oct 17, 2026
200 of 202 checks passed
@steipete
steipete deleted the codex/tts-output-extension branch October 17, 2026 16:06
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…claw#175615)

infer tts convert --output copied the provider audio to the requested
path verbatim, so Google's WAV landed in a .mp3 file. Route it through the
shared media output writer that image and video generation already use,
which keeps a matching extension and replaces a mismatched one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant