---
image: https://remotion.media/docs/generated/articles-docs-whisper-webgpu-transcribe.png
title: transcribe()
crumb: '@remotion/whisper-webgpu'
---

# transcribe()<AvailableFrom v="4.0.518" />

Transcribes a 16kHz mono waveform and returns words with start and end timestamps.

The downloaded model is loaded automatically if needed.

```ts twoslash title="transcribe.ts"
import {downloadWhisperModel, resampleTo16Khz, transcribe} from '@remotion/whisper-webgpu';

await downloadWhisperModel({model: 'small.en'});
const file = new File([], 'audio.wav');
const channelWaveform = await resampleTo16Khz({file});

const result = await transcribe({
  channelWaveform,
  model: 'small.en',
});

console.log(result.text, result.words);
```

## Options

### channelWaveform

A mono `Float32Array` sampled at 16kHz. Use [`resampleTo16Khz()`](/docs/whisper-webgpu/resample-to-16khz) for browser audio files.

### model

One of the timestamped models returned by [`getAvailableModels()`](/docs/whisper-webgpu/get-available-models). `small` or `small.en` is the recommended default.

### language?

The spoken language name or language code. This option is required for multilingual models because automatic language detection is not supported. Omit it for English-only models such as `small.en`.

### task?<AvailableFrom v="4.0.523" />

Either `transcribe` or `translate`. Default: `transcribe`.

`translate` translates speech into English and is supported by multilingual non-turbo models only. Check the model's `supportsTranslation` property before using it. Word timestamps may be less reliable when translating.

### chunkLengthInSeconds?

Length of long-audio chunks. Default: `30`. Must be a finite number greater than `0`.

### strideLengthInSeconds?

Overlap on both sides of a chunk. Default: `5`. Must be finite, non-negative, and less than half of `chunkLengthInSeconds`.

### forceFullSequences?<AvailableFrom v="4.0.523" />

Whether every sequence must end with a timestamp. Default: `false`. Must be a boolean. When set to `true`, transcription throws if the model returns a trailing sequence without an ending timestamp.

### doSample?<AvailableFrom v="4.0.523" />

Whether to sample tokens probabilistically instead of always choosing the most likely token. Default: `false`. Must be a boolean. Sampling can produce different results between runs.

### temperature?<AvailableFrom v="4.0.523" />

Controls randomness when `doSample` is `true`. Default: `1`. Must be a finite number greater than `0`; lower values favor more likely tokens.

### topK?<AvailableFrom v="4.0.523" />

Limits sampling to the tokens with the highest probabilities when `doSample` is `true`. Default: `50`. Must be a non-negative integer; `0` disables the limit.

### repetitionPenalty?<AvailableFrom v="4.0.523" />

Adjusts the probability of tokens that have already been generated. Default: `1`, which applies no penalty. Must be a finite number greater than `0`; values above `1` discourage repetition and values below `1` encourage it.

### noRepeatNgramSize?<AvailableFrom v="4.0.523" />

Prevents a generated token sequence of this length from occurring more than once. Default: `0`, which disables the constraint. Must be a non-negative integer.

### onModelLoadProgress?

Called while a previously downloaded model is initialized. Call [`downloadWhisperModel()`](/docs/whisper-webgpu/download-whisper-model) first to download the files and receive download progress.

The callback receives the same object as the [`onProgress`](/docs/whisper-webgpu/load-whisper-model#onprogress) callback of [`loadWhisperModel()`](/docs/whisper-webgpu/load-whisper-model).

### signal?<AvailableFrom v="4.0.528" />

An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) for canceling transcription.  
Calling `abort()` on its controller stops token generation and rejects the promise with the signal's reason.  
A GPU operation already in progress must finish first.  
No partial transcript is returned.

```ts twoslash title="cancel-transcription.ts"
import {transcribe} from '@remotion/whisper-webgpu';

declare const channelWaveform: Float32Array;
// ---cut---
const controller = new AbortController();
document.querySelector('button')?.addEventListener('click', () => {
  controller.abort();
});

const result = await transcribe({
  channelWaveform,
  model: 'small.en',
  signal: controller.signal,
});
```

## Return value

An object with the following properties:

### `text`

The full transcription text.

### `words`

An array of transcribed words. Each word has the following properties:

#### `text`

The text of the word.

#### `startInSeconds`

The start time of the word in seconds.

#### `endInSeconds`

The end time of the word in seconds.

### `model`

The model that was used for transcription.

Word-level timestamps are returned after transcription completes. [Transformers.js](https://huggingface.co/docs/transformers.js) does not currently stream word-aligned updates while inference is running.

## Compatibility

<CompatibilityTable chrome firefox safari nodejs={true} bun={true} serverlessFunctions={false} clientSideRendering={false} serverSideRendering player studio />

## See also

- [`toCaptions()`](/docs/whisper-webgpu/to-captions)
- [`getAvailableModels()`](/docs/whisper-webgpu/get-available-models)
