From a45e38afbb0857e69e9627f768a3ea84b83030b9 Mon Sep 17 00:00:00 2001 From: will wade Date: Sun, 16 Aug 2026 09:37:02 +0000 Subject: [PATCH] fix(google): pin MP3 output to 24 kHz Without sampleRateHertz Google returns audio at each voice's natural rate (22050/24000/32000 depending on model family), so downstream consumers that receive bare PCM via on_audio cannot know the rate. Pinning 24000 makes the delivery rate deterministic for every voice. --- src/cloud_engine.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cloud_engine.rs b/src/cloud_engine.rs index 4904add..9b6f3e2 100644 --- a/src/cloud_engine.rs +++ b/src/cloud_engine.rs @@ -1102,7 +1102,10 @@ fn build_google_request( let mut body = serde_json::json!({ "input": input, "voice": voice_obj, - "audioConfig": { "audioEncoding": "MP3" } + // sampleRateHertz is pinned so the decoded PCM rate is knowable by + // callers that receive bare bytes via on_audio (Google otherwise + // returns each voice's natural rate: 22050/24000/32000). + "audioConfig": { "audioEncoding": "MP3", "sampleRateHertz": 24000 } }); if add_marks {