From c7d20aa9ecd34fec0b51644d207441489b23c1c3 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Sun, 26 Apr 2026 10:21:50 +0200 Subject: [PATCH] fix(deepgram): remove double URL-encoding of STT query parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `URL.searchParams.append()` already percent-encodes values on serialization. The extra `encodeURIComponent()` call causes double-encoding for non-ASCII characters (Thai, Chinese, etc.): encodeURIComponent("ครับ") → "%E0%B8%84..." searchParams.append re-encodes % → "%25E0%25B8%2584..." This means: 1. Non-Latin keyterms arrive at Deepgram as percent-encoded strings instead of actual text, making keyterm prompting ineffective. 2. The inflated URL length hits Deepgram's limits sooner — in our testing, 13 Thai keyterms triggered a 400 rejection. Latin-only keyterms are unaffected because encodeURIComponent is a no-op for ASCII letters/digits, so this has been invisible to English users. The fix: let searchParams.append handle encoding on its own. --- plugins/deepgram/src/stt.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/deepgram/src/stt.ts b/plugins/deepgram/src/stt.ts index 0f10ee331..870685e66 100644 --- a/plugins/deepgram/src/stt.ts +++ b/plugins/deepgram/src/stt.ts @@ -198,9 +198,9 @@ export class SpeechStream extends stt.SpeechStream { Object.entries(params).forEach(([k, v]) => { if (v !== undefined) { if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean') { - streamURL.searchParams.append(k, encodeURIComponent(v)); + streamURL.searchParams.append(k, String(v)); } else { - v.forEach((x) => streamURL.searchParams.append(k, encodeURIComponent(x))); + v.forEach((x) => streamURL.searchParams.append(k, x)); } } });