Skip to main content
Version: 0.10.0

Type Alias: WhisperSpeechToText<L>

WhisperSpeechToText<L> = object

Defined in: extensions/speech/tasks/whisperSpeechToText.ts:108

Whisper speech-to-text task runner.

Type Parameters​

L​

L extends WhisperLanguage = WhisperLanguage

The language type accepted by the model.

Properties​

dispose()​

readonly dispose: () => void

Defined in: extensions/speech/tasks/whisperSpeechToText.ts:112

Releases all allocated native resources.

Returns​

void


stream()​

readonly stream: (options) => AsyncGenerator<{ committed: string; nonCommitted: string; }>

Defined in: extensions/speech/tasks/whisperSpeechToText.ts:160

Async generator for real-time microphone transcription. Feed audio with streamInsert and stop with streamStop. Yields { committed, nonCommitted } on every VAD or transcription event: committed is the finalized transcript so far; nonCommitted is the in-progress text that may still change.

Parameters​

options​

WhisperStreamOptions<L>

Stream options (language and optional VAD tuning). See WhisperStreamOptions.

Returns​

AsyncGenerator<{ committed: string; nonCommitted: string; }>

An AsyncGenerator yielding transcript updates.

Throws​

With code INVALID_ARGUMENT if the language is unsupported, RESOURCE_BUSY if the model is in use, or RESOURCE_DISPOSED if disposed.


streamInsert()​

readonly streamInsert: (audioChunk) => void

Defined in: extensions/speech/tasks/whisperSpeechToText.ts:176

Appends a new PCM chunk to the live streaming buffer consumed by stream. Ignored when streaming is not active.

Parameters​

audioChunk​

Float32Array

The newly captured audio samples (16 kHz mono Float32 PCM).

Returns​

void


streamStop()​

readonly streamStop: () => void

Defined in: extensions/speech/tasks/whisperSpeechToText.ts:168

Signals the stream generator to finalize the current segment and return. Safe to call even when streaming is not active.

Returns​

void


transcribe()​

readonly transcribe: (audio, options, onToken?) => Promise<string>

Defined in: extensions/speech/tasks/whisperSpeechToText.ts:126

Asynchronously transcribes a pre-recorded mono waveform sampled at WHISPER_SAMPLE_RATE_HZ.

Parameters​

audio​

Float32Array

Raw 16 kHz mono PCM audio samples (Float32Array).

options​

WhisperSttOptions<L>

Transcription options. See WhisperSttOptions.

onToken?​

(token) => void

Optional callback fired on the RN thread for each decoded token.

Returns​

Promise<string>

A promise resolving to the full transcript string.

Throws​

With code INVALID_ARGUMENT if the language is unsupported, RESOURCE_BUSY if the model is in use, or RESOURCE_DISPOSED if disposed.


transcribeStop()​

readonly transcribeStop: () => void

Defined in: extensions/speech/tasks/whisperSpeechToText.ts:145

Interrupts and stops any active transcription call.

Returns​

void


transcribeWorklet()​

readonly transcribeWorklet: (audio, options, onToken?) => string

Defined in: extensions/speech/tasks/whisperSpeechToText.ts:136

Synchronous version of transcribe to be executed directly on the caller or worklet thread.

Parameters​

audio​

Float32Array

options​

WhisperSttOptions<L>

onToken?​

(token) => void

Returns​

string