omi icon indicating copy to clipboard operation
omi copied to clipboard

TypeScript SDK silently ignores an explicit Whisper sampleRate

Open PlayerBC opened this issue 2 months ago • 2 comments

At 2654b4dc9bb9e5277a5db567214a674c092d2fd8, the TypeScript SDK's shared createTranscriber() accepts sampleRate, but its Whisper branch drops that option and batches at a hard-coded 16,000 Hz. With sampleRate: 8000, five seconds of mono s16le input (80,000 bytes) does not invoke the injected runner; ten seconds (160,000 bytes) does. The device PCM contract specifies 16 kHz, so an explicit unsupported rate should be rejected instead of silently accepted. This is a configuration-validation mismatch, not a claim of measured production data loss.

Reproduction with Node 24.19.0 from a checkout, using synthetic PCM and the production export:

import { createTranscriber } from './sdks/device/typescript/src/stt/index.ts';
const batches = [];
const t = createTranscriber('whisper', {
  sampleRate: 8000,
  whisperRunner: pcm => { batches.push(pcm.byteLength); return 'synthetic'; },
  onTranscript() {},
});
t.appendPcm(new Uint8Array(80000));
await new Promise(setImmediate);
console.log(batches); // []
t.appendPcm(new Uint8Array(80000));
await new Promise(setImmediate);
console.log(batches); // [160000]
t.stop();

A three-line candidate in the Whisper factory branch rejects a supplied rate other than 16,000:

if (opts.sampleRate !== undefined && opts.sampleRate !== 16000) {
  throw new Error('Whisper requires 16000 Hz PCM; resample audio before transcription');
}

Ten focused Node tests execute the original source or that candidate: five unsupported-rate checks fail before the change, all ten pass after it. Controls retain omitted/explicit 16 kHz batching, the missing-runner error, and custom-rate forwarding for Deepgram and Parakeet. The unmodified source snapshot matches Git blob 0be2360428a644a9c83a391ce6f620261df49628. No model, hardware, credentials, or live service was used. These are focused checks, not the full Bun SDK suite, typecheck, or repository preflight; those remain required before a PR is ready.

Following the contribution guide, @josancamon19: would you approve US$10, payable through the documented private PayPal process after acceptance and merge, for this validation, native SDK regression tests, and a short README clarification? Please confirm that fail-fast validation is the desired contract before I submit the integration. No bounty funding, assignment, or payment is assumed.

PlayerBC avatar Sep 08 '26 15:09 PlayerBC

I have implemented this fix and added unit tests in PR #13313.

/claim #13122

CreamPle avatar Sep 09 '26 13:09 CreamPle

Thanks for putting this together. We aren't doing bounties at the moment, so we're closing the bounty proposal issues for now — thanks for the fix! 🙏

aryanorastar avatar Nov 05 '26 16:11 aryanorastar