Skip to content

fix: choose speech SDK sample rate from audio format - #305

Merged
NianJiuZst merged 1 commit into
MiniMax-AI:mainfrom
Ricardo-M-L:codex/speech-sdk-format-defaults-20261109
Nov 9, 2026
Merged

NianJiuZst merged 1 commit into
MiniMax-AI:mainfrom
Ricardo-M-L:codex/speech-sdk-format-defaults-20261109

Conversation

@Ricardo-M-L

@Ricardo-M-L Ricardo-M-L commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem

SpeechSDK.synthesize({ text, audio_setting: { format: 'pcmu_wav' } }) currently sends a 32 kHz sample rate, even though the T2A API documentation describes PCM μ-law output as 8 kHz. The CLI already chooses 8 kHz for both PCM μ-law formats and 24 kHz for Opus when no sample rate is specified, but the SDK always injects 32 kHz.

Change

Use the existing format-aware default in SDK synthesis, for both streaming and non-streaming requests. Preserve explicit sample rates and other caller-provided settings. Make the shared default lookup ignore inherited properties so unknown format strings such as constructor continue to use the numeric fallback rather than causing a missing or nonnumeric sample rate.

The Opus default matches existing CLI behavior; no claim is made that 24 kHz is the only rate accepted by the API. The SDK continues to pass unknown formats through to the API as before.

Validation

  • Before the fix, offline mock-request regressions for opus, pcmu_raw, and pcmu_wav sent 32000 rather than the expected defaults; after the initial fix, tests for three inherited-property names reproduced an omitted or nonnumeric rate and pass with the guarded lookup.
  • bun test test/sdk/speech.test.ts test/commands/speech/synthesize.test.ts — 65 passed; covers every supported format, unknown/prototype names, explicit options, defaults, and streaming.
  • bun run typecheck — passed.
  • bun run lint — passed with one existing no-explicit-any warning in the speech test file.
  • bun run build and git diff --check — passed.
  • Two independent blind reviews of the final diff found no blocking issues. Their focused checks passed (40 and 90 tests respectively).

No live or paid synthesis request was made; tests capture local mock requests and do not verify provider behavior.

AI assistance: Codex investigated, implemented, and tested this change with independent AI-assisted review.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@Ricardo-M-L
Ricardo-M-L marked this pull request as ready for review November 8, 2026 18:57

@NianJiuZst NianJiuZst 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.

Approve

@NianJiuZst
NianJiuZst merged commit d173e55 into MiniMax-AI:main Nov 9, 2026
3 checks passed
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.

2 participants