Transcription · Transcribe an audio file1 / 7
  1. 02
  2. 03
  3. 04
  4. 05
  5. 06
  6. 07

Transcribe an audio file

Example on GitHub(packages/sdk/examples/transcription/whispercpp-filesystem.ts)

We're starting a new chapter on transcription, and we're going to turn a WAV file into text.

Whisper takes a WAV file and returns the spoken text. The SDK wraps it in one transcribe() call. The result is an array of segments with start and end timestamps, so we can render captions, search inside audio, or chunk the transcript by speaker turn.

WHISPER_TINY is the smallest Whisper model in the SDK.

Setting metadata: true is what brings back the per-segment timestamps. You would call it like so:

const segments = await transcribe({
  modelId,
  audioChunk: "./examples/qvac/transcription/input/sample-16khz.wav",
  metadata: true,
});

for (const segment of segments) {
  const start = (segment.startMs / 1000).toFixed(2);
  const end = (segment.endMs / 1000).toFixed(2);
  console.log(`[${start}s → ${end}s] ${segment.text}`);
}

The metadata: true flag keeps the per-segment timing fields. We set it to false if we only need the joined text.

Note: the audio must be a WAV file at 16 kHz mono PCM. Other formats work with extra conversion, but the SDK takes the most common shape directly.

Put it to the test

  1. Call transcribe({ modelId, audioChunk: <path>, metadata: true }), await the segments, and loop through them logging each with its [start → end] timestamp.
index.ts

$ Run your code to see results

$