From 6f07261ef3d22f77b2aa4be9a7c6702e352172bc Mon Sep 17 00:00:00 2001 From: Angelo Giacco Date: Wed, 15 Apr 2026 14:33:04 +0100 Subject: [PATCH] enable zrm scribe --- packages/client/src/scribe/scribe.test.ts | 56 +++++++++++++++++++++++ packages/client/src/scribe/scribe.ts | 11 +++++ packages/react/src/scribe.ts | 12 +++++ 3 files changed, 79 insertions(+) diff --git a/packages/client/src/scribe/scribe.test.ts b/packages/client/src/scribe/scribe.test.ts index eb6b25f1e..faefb4db6 100644 --- a/packages/client/src/scribe/scribe.test.ts +++ b/packages/client/src/scribe/scribe.test.ts @@ -91,6 +91,62 @@ describe("Scribe", () => { server.close(); }); + it("builds URI with enableLogging set to false", () => { + const server = new Server( + "wss://api.elevenlabs.io/v1/speech-to-text/realtime?model_id=scribe_v2_realtime&token=sutkn_123&enable_logging=false" + ); + + const connection = Scribe.connect({ + token: TEST_TOKEN, + modelId: TEST_MODEL_ID, + audioFormat: AudioFormat.PCM_16000, + sampleRate: 16000, + enableLogging: false, + }); + + expect(connection).toBeDefined(); + + connection.close(); + server.close(); + }); + + it("builds URI with enableLogging set to true", () => { + const server = new Server( + "wss://api.elevenlabs.io/v1/speech-to-text/realtime?model_id=scribe_v2_realtime&token=sutkn_123&enable_logging=true" + ); + + const connection = Scribe.connect({ + token: TEST_TOKEN, + modelId: TEST_MODEL_ID, + audioFormat: AudioFormat.PCM_16000, + sampleRate: 16000, + enableLogging: true, + }); + + expect(connection).toBeDefined(); + + connection.close(); + server.close(); + }); + + it("omits enable_logging from URI when not specified", () => { + const server = new Server( + "wss://api.elevenlabs.io/v1/speech-to-text/realtime?model_id=scribe_v2_realtime&token=sutkn_123" + ); + + const connection = Scribe.connect({ + token: TEST_TOKEN, + modelId: TEST_MODEL_ID, + audioFormat: AudioFormat.PCM_16000, + sampleRate: 16000, + }); + + expect(connection).toBeDefined(); + + connection.close(); + server.close(); + }); + it("throws error when modelId is missing", () => { expect(() => { Scribe.connect({ diff --git a/packages/client/src/scribe/scribe.ts b/packages/client/src/scribe/scribe.ts index 785bf85ed..181a26d32 100644 --- a/packages/client/src/scribe/scribe.ts +++ b/packages/client/src/scribe/scribe.ts @@ -66,6 +66,11 @@ interface BaseOptions { * @default false */ includeTimestamps?: boolean; + /** + * Whether to enable logging for this session. + * When set to false, logging will be disabled. + */ + enableLogging?: boolean; } export interface AudioOptions extends BaseOptions { @@ -172,6 +177,12 @@ export class ScribeRealtime { options.includeTimestamps ? "true" : "false" ); } + if (options.enableLogging !== undefined) { + params.append( + "enable_logging", + options.enableLogging ? "true" : "false" + ); + } const queryString = params.toString(); return queryString ? `${baseUri}?${queryString}` : baseUri; diff --git a/packages/react/src/scribe.ts b/packages/react/src/scribe.ts index 218d701a8..5af05464b 100644 --- a/packages/react/src/scribe.ts +++ b/packages/react/src/scribe.ts @@ -113,6 +113,9 @@ export interface ScribeHookOptions extends ScribeCallbacks { // Include timestamps includeTimestamps?: boolean; + + // Logging + enableLogging?: boolean; } export interface UseScribeReturn { @@ -186,6 +189,9 @@ export function useScribe(options: ScribeHookOptions = {}): UseScribeReturn { // Timestamps includeTimestamps: defaultIncludeTimestamps, + + // Logging + enableLogging: defaultEnableLogging, } = options; const connectionRef = useRef(null); @@ -242,6 +248,9 @@ export function useScribe(options: ScribeHookOptions = {}): UseScribeReturn { onCommittedTranscriptWithTimestamps ); + const enableLogging = + runtimeOptions.enableLogging ?? defaultEnableLogging; + if (microphone) { // Microphone mode connection = Scribe.connect({ @@ -262,6 +271,7 @@ export function useScribe(options: ScribeHookOptions = {}): UseScribeReturn { languageCode: runtimeOptions.languageCode || defaultLanguageCode, microphone, includeTimestamps, + enableLogging, } as MicrophoneOptions); } else if (audioFormat && sampleRate) { // Manual audio mode @@ -282,6 +292,7 @@ export function useScribe(options: ScribeHookOptions = {}): UseScribeReturn { defaultMinSilenceDurationMs, languageCode: runtimeOptions.languageCode || defaultLanguageCode, includeTimestamps, + enableLogging, audioFormat, sampleRate, } as AudioOptions); @@ -464,6 +475,7 @@ export function useScribe(options: ScribeHookOptions = {}): UseScribeReturn { defaultAudioFormat, defaultSampleRate, defaultIncludeTimestamps, + defaultEnableLogging, onSessionStarted, onPartialTranscript, onCommittedTranscript,