Skip to main content
Version: Next

Interface: SpeechToTextType

Defined in: types/stt.ts:25

React hook for managing Speech to Text (STT) instance.

Properties

downloadProgress

downloadProgress: number

Defined in: types/stt.ts:44

Tracks the progress of the model download process.


error

error: RnExecutorchError | null

Defined in: types/stt.ts:29

Contains the error message if the model failed to load.


isGenerating

isGenerating: boolean

Defined in: types/stt.ts:39

Indicates whether the model is currently processing an inference.


isReady

isReady: boolean

Defined in: types/stt.ts:34

Indicates whether the model has successfully loaded and is ready for inference.

Methods

decode()

decode(tokens, encoderOutput): Promise<Float32Array<ArrayBufferLike>>

Defined in: types/stt.ts:59

Runs the decoder of the model.

Parameters

tokens

Int32Array

The encoded audio data.

encoderOutput

Float32Array

The output from the encoder.

Returns

Promise<Float32Array<ArrayBufferLike>>

A promise resolving to the decoded text.


encode()

encode(waveform): Promise<Float32Array<ArrayBufferLike>>

Defined in: types/stt.ts:51

Runs the encoding part of the model on the provided waveform.

Parameters

waveform

Float32Array

The input audio waveform array.

Returns

Promise<Float32Array<ArrayBufferLike>>

A promise resolving to the encoded data.


stream()

stream(options?): AsyncGenerator<{ committed: TranscriptionResult; nonCommitted: TranscriptionResult; }, void, unknown>

Defined in: types/stt.ts:84

Starts a streaming transcription process. Use in combination with streamInsert to feed audio chunks and streamStop to end the stream. Updates committedTranscription and nonCommittedTranscription as transcription progresses.

Parameters

options?

DecodingOptions

Decoding options including language.

Returns

AsyncGenerator<{ committed: TranscriptionResult; nonCommitted: TranscriptionResult; }, void, unknown>

Asynchronous generator that returns committed and nonCommitted transcription. Both committed and nonCommitted are of type TranscriptionResult


streamInsert()

streamInsert(waveform): void

Defined in: types/stt.ts:97

Inserts a chunk of audio data (sampled at 16kHz) into the ongoing streaming transcription.

Parameters

waveform

Float32Array

The audio chunk to insert.

Returns

void


streamStop()

streamStop(): void

Defined in: types/stt.ts:102

Stops the ongoing streaming transcription process.

Returns

void


transcribe()

transcribe(waveform, options?): Promise<TranscriptionResult>

Defined in: types/stt.ts:71

Starts a transcription process for a given input array, which should be a waveform at 16kHz.

Parameters

waveform

Float32Array

The input audio waveform.

options?

DecodingOptions

Decoding options, check API reference for more details.

Returns

Promise<TranscriptionResult>

Resolves a promise with the output transcription. Result of transcription is object of type TranscriptionResult.