Make every audio buffer's declared sample rate match its bytes
Resamplers and transports trust the rate they are told. In one case a recording buffer had no explicit rate and inherited the bot's output rate, so inbound carrier frames were resampled as the wrong rate and the carrier channel sounded robotic, even though the WAV header looked correct. In another, STT input moved to 48 kHz while the replay harness still generated 8 or 16 kHz audio labelled 48 kHz. The new unit test checked only the config value, so replay results were quietly wrong. Set the rate explicitly on every buffer, generate test audio and chunk sizes from the same setting the transport declares, and assert that bytes per frame divided by frame duration equals the expected rate. A 20 ms frame-size check before resampling catches most mismatches.
Applies when: audio moves between telephony, TTS, STT, recording and replay components with different native rates. Keywords: sample rate mismatch resampling PCM frame size 8 kHz 16 kHz 48 kHz Pipecat TTS STT replay recording robotic audio distortion