Skip to content

server : reject a realtime session.update with another sample rate - #31697

Closed
T0mSIlver wants to merge 2 commits into
ggml-org:masterfrom
T0mSIlver:realtime-rate-master
Closed

T0mSIlver wants to merge 2 commits into
ggml-org:masterfrom
T0mSIlver:realtime-rate-master

Conversation

@T0mSIlver

Copy link
Copy Markdown
Contributor

Overview

Fixes #31696.

A session.update whose audio.input.format.rate is not the model's sample rate now gets an error event (audio.input.format.rate must be 16000), and the session keeps its previous settings. Updates that don't set a rate behave as before. The check compares the JSON value itself, so the string "24000" and 16000.5 are rejected too.

It also replaces a README note, out of date since #30994, that said held-back words go to the next item.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES. Claude Code wrote the change and drafted this description, Codex reviewed the diff, and I reviewed both.

@candrews

candrews commented Nov 7, 2026

Copy link
Copy Markdown

OpenAI’s realtime PCM format uses 24 kHz, which clients send and expect to work.

Instead of rejecting, the audio should be resampled/transcoded, which was noted in the original realtime PR as a follow up at #30636 (review)

The input rate of a realtime session is 24000 Hz, like OpenAI's audio/pcm,
unless session.update sets audio.input.format.rate before the first audio.
The server resamples the audio to the model rate with a new mtmd helper
that wraps the miniaudio resampler, in transcription and conversation
sessions.
@T0mSIlver
T0mSIlver requested a review from a team as a code owner November 7, 2026 12:10
@github-actions github-actions Bot added the mtmd Related to multimodal functionality (video/image/audio) label Nov 7, 2026
std::vector<float> out;
};

mtmd_helper_resampler * mtmd_helper_resampler_init(int32_t rate_in, int32_t rate_out) {

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.

is this even related to this PR?

you said that mismatching sample rate is reject? then why adding a brand new resampler out of nowhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, my mistake: I pushed the rework with the resampling before explaining it, and the title and description still describe the old change (rejection only).

I added the resampler following @candrews's comment above, which points to @ServeurpersoCom's note in #30636: "24 kHz input with server side resampling, so any OAI client works without knowing the model rate". The server can't call miniaudio directly, since it's compiled into libmtmd as static functions, hence the helper.

Would you rather have resampling, in a new PR or this one reopened, or only the original rejection? And if resampling, is mtmd-helper the right place?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I suspect this PR is off everyone's radar since it's closed and the title is no longer accurate with the planned change.

I suggest opening a new one.

@ngxson ngxson closed this Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation mtmd Related to multimodal functionality (video/image/audio) server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misc. bug: server: realtime session.update asking for 24 kHz is accepted, the audio is still read as 16 kHz

3 participants