Repository navigation
fix: choose speech SDK sample rate from audio format - #305
Merged
NianJiuZst merged 1 commit intoNov 9, 2026
Merged
NianJiuZst merged 1 commit into
NianJiuZst merged 1 commit into
Conversation
Ricardo-M-L
marked this pull request as ready for review
November 8, 2026 18:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
constructorcontinue 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
opus,pcmu_raw, andpcmu_wavsent 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 existingno-explicit-anywarning in the speech test file.bun run buildandgit diff --check— passed.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.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.