fix(typescript-sdk): reject unsupported Whisper sampleRate

Closed
DA
3mo ago
+69-1

Summary

Fixes #13122.

createTranscriber() already accepts sampleRate, but the Whisper branch dropped it and batched PCM at a hard-coded 16 kHz. Five seconds of explicit 8 kHz mono s16le (80,000 bytes) therefore never flushed; ten seconds (160,000 bytes) did, because the window was still measured as 16 kHz.

The device PCM contract is 16 kHz. An explicit unsupported rate is now rejected at construction instead of being silently ignored. Omitted sampleRate and explicit 16000 keep the existing 16 kHz batching. Deepgram/Parakeet URL handling is unchanged.

Verification

From sdks/device/typescript:

bun test src/stt/index.test.ts

18 passed (existing STT suite plus the sampleRate cases). Node 22 strip-types contract checks also passed: 8 kHz/44.1 kHz throw before the Whisper runner is invoked.

Made with Cursor