Performs speech-to-text transcription on audio data.
Signature:
export declare class AudioTranscriber extends TaskRunner
Extends: TaskRunner
Methods
| Method | Modifiers | Description |
|---|---|---|
| close() | Releases all native WASM resources held by this transcriber. | |
| createFromModelBuffer(wasmFileset, modelAssetBuffer) | static |
Initializes the Wasm runtime and creates a new audio transcriber based on the provided model asset buffer. |
| createFromModelPath(wasmFileset, modelAssetPath) | static |
Initializes the Wasm runtime and creates a new audio transcriber based on the path to the model asset. |
| createFromOptions(wasmFileset, options) | static |
Initializes the Wasm runtime and creates a new audio transcriber from the provided options. |
| finishStream() | Signals the end of a streaming audio session and returns any remaining finalized transcription segments. | |
| prewarm() | Pre-warms the ASR engine by running a dummy inference pass so that subsequent transcribe() calls have minimal startup latency. |
|
| setOptions(options) | Sets new options for the audio transcriber. | |
| transcribe(audioSamples, endOfStream) | Transcribes a complete audio buffer in a single call. | |
| transcribeStream(audioSamples) | Feeds a chunk of streaming audio samples into the transcriber and returns any available segments. |
AudioTranscriber.close()
Releases all native WASM resources held by this transcriber.
Signature:
close(): void;
Returns:
void
AudioTranscriber.createFromModelBuffer()
Initializes the Wasm runtime and creates a new audio transcriber based on the provided model asset buffer.
Signature:
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array | ReadableStreamDefaultReader): Promise<AudioTranscriber>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetBuffer | Uint8Array | ReadableStreamDefaultReader | A binary representation of the model or a stream reader. |
Returns:
Promise<AudioTranscriber>
AudioTranscriber.createFromModelPath()
Initializes the Wasm runtime and creates a new audio transcriber based on the path to the model asset.
Signature:
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: TrustedResourceUrl | string): Promise<AudioTranscriber>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetPath | TrustedResourceUrl | string | The path to the model asset. |
Returns:
Promise<AudioTranscriber>
AudioTranscriber.createFromOptions()
Initializes the Wasm runtime and creates a new audio transcriber from the provided options.
Signature:
static createFromOptions(wasmFileset: WasmFileset, options: AudioTranscriberOptions): Promise<AudioTranscriber>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| options | AudioTranscriberOptions | The options for the audio transcriber. |
Returns:
Promise<AudioTranscriber>
AudioTranscriber.finishStream()
Signals the end of a streaming audio session and returns any remaining finalized transcription segments.
Signature:
finishStream(): Promise<AudioTranscriberResult>;
Returns:
Promise<AudioTranscriberResult>
AudioTranscriber.prewarm()
Pre-warms the ASR engine by running a dummy inference pass so that subsequent transcribe() calls have minimal startup latency.
Signature:
prewarm(): Promise<void>;
Returns:
Promise<void>
AudioTranscriber.setOptions()
Sets new options for the audio transcriber.
Signature:
setOptions(options: AudioTranscriberOptions): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| options | AudioTranscriberOptions | New options to apply. |
Returns:
Promise<void>
AudioTranscriber.transcribe()
Transcribes a complete audio buffer in a single call.
Signature:
transcribe(audioSamples: Float32Array | number[], endOfStream?: boolean): Promise<AudioTranscriberResult>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| audioSamples | Float32Array | number[] | Mono PCM audio samples in the range [-1.0, 1.0]. |
| endOfStream | boolean | Whether this buffer marks the end of the audio stream (defaults to true). |
Returns:
Promise<AudioTranscriberResult>
AudioTranscriber.transcribeStream()
Feeds a chunk of streaming audio samples into the transcriber and returns any available segments. Call finishStream() when the stream ends.
Signature:
transcribeStream(audioSamples: Float32Array | number[]): Promise<AudioTranscriberResult>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| audioSamples | Float32Array | number[] | Mono PCM audio samples in the range [-1.0, 1.0]. |
Returns:
Promise<AudioTranscriberResult>