From 35226703ce7b0a032fa309d48f31a762c55b8c9a Mon Sep 17 00:00:00 2001 From: AssemblyAI Date: Tue, 19 May 2026 10:25:35 -0400 Subject: [PATCH] Project import generated by Copybara. GitOrigin-RevId: 0570d5ed67c6ebb9780cf3edd4ab2ef34c721511 --- package.json | 2 +- src/services/streaming/service.ts | 7 +++++++ src/types/streaming/index.ts | 2 ++ tests/unit/streaming.test.ts | 31 +++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f74d41..ed50085 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "assemblyai", - "version": "4.33.2", + "version": "4.33.3", "description": "The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.", "engines": { "node": ">=18" diff --git a/src/services/streaming/service.ts b/src/services/streaming/service.ts index bb18ffc..636c561 100644 --- a/src/services/streaming/service.ts +++ b/src/services/streaming/service.ts @@ -205,6 +205,13 @@ export class StreamingTranscriber { ); } + if (this.params.turnLeftPadMs !== undefined) { + searchParams.set( + "turn_left_pad_ms", + this.params.turnLeftPadMs.toString(), + ); + } + if (this.params.customerSupportAudioCapture) { console.warn( "`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support.", diff --git a/src/types/streaming/index.ts b/src/types/streaming/index.ts index f25584c..3f5f2e9 100644 --- a/src/types/streaming/index.ts +++ b/src/types/streaming/index.ts @@ -40,6 +40,7 @@ export type StreamingTranscriberParams = { voiceFocusThreshold?: number; continuousPartials?: boolean; interruptionDelay?: number; + turnLeftPadMs?: number; customerSupportAudioCapture?: boolean; includePartialTurns?: boolean; redactPii?: boolean; @@ -221,6 +222,7 @@ export type StreamingUpdateConfiguration = { prompt?: string; filter_profanity?: boolean; interruption_delay?: number; + turn_left_pad_ms?: number; }; export type StreamingForceEndpoint = { diff --git a/tests/unit/streaming.test.ts b/tests/unit/streaming.test.ts index b05a7c3..4b86651 100644 --- a/tests/unit/streaming.test.ts +++ b/tests/unit/streaming.test.ts @@ -204,6 +204,37 @@ describe("streaming", () => { ); }); + it("should include turn_left_pad_ms in connection URL", async () => { + await cleanup(); + WS.clean(); + + const wsUrl = + `${websocketBaseUrl}?token=123&sample_rate=16000` + + `&speech_model=u3-rt-pro` + + `&turn_left_pad_ms=1024`; + server = new WS(wsUrl); + rt = new StreamingTranscriber({ + websocketBaseUrl, + token: "123", + sampleRate: 16_000, + speechModel: "u3-rt-pro", + turnLeftPadMs: 1024, + }); + onOpen = jest.fn(); + rt.on("open", onOpen); + await connect(rt, server); + }); + + it("should include turn_left_pad_ms in updateConfiguration message", async () => { + rt.updateConfiguration({ turn_left_pad_ms: 1024 }); + await expect(server).toReceiveMessage( + JSON.stringify({ + type: "UpdateConfiguration", + turn_left_pad_ms: 1024, + }), + ); + }); + it("should include voice_focus and voice_focus_threshold in connection URL", async () => { await cleanup(); WS.clean();