Skip to main content
Version: Next

Function: useSpeechToText()

Call Signature​

useSpeechToText<L>(config, options?): object

Defined in: hooks/useSpeechToText.ts:32

React hook to load and run a Whisper speech-to-text (ASR) model.

This hook manages downloading (if remote URLs are provided) and loading the model assets, tokenizer, and voice activity detector, tracking download progress and load errors, and releasing native memory when the component unmounts or the configuration changes.

For imperative usage, see createWhisperSpeechToText.

Type Parameters​

L​

L extends "en" | "zh" | "de" | "es" | "ru" | "ko" | "fr" | "ja" | "pt" | "tr" | "pl" | "ca" | "nl" | "ar" | "sv" | "it" | "id" | "hi" | "fi" | "vi" | "he" | "uk" | "el" | "ms" | "cs" | "ro" | "da" | "hu" | "ta" | "no" | "th" | "ur" | "hr" | "bg" | "lt" | "la" | "mi" | "ml" | "cy" | "sk" | "te" | "fa" | "lv" | "bn" | "sr" | "az" | "sl" | "kn" | "et" | "mk" | "br" | "eu" | "is" | "hy" | "ne" | "mn" | "bs" | "kk" | "sq" | "sw" | "gl" | "mr" | "pa" | "si" | "km" | "sn" | "yo" | "so" | "af" | "oc" | "ka" | "be" | "tg" | "sd" | "gu" | "am" | "yi" | "lo" | "uz" | "fo" | "ht" | "ps" | "tk" | "nn" | "mt" | "sa" | "lb" | "my" | "bo" | "tl" | "mg" | "as" | "tt" | "haw" | "ln" | "ha" | "ba" | "jw" | "su" | "yue" = "en" | "zh" | "de" | "es" | "ru" | "ko" | "fr" | "ja" | "pt" | "tr" | "pl" | "ca" | "nl" | "ar" | "sv" | "it" | "id" | "hi" | "fi" | "vi" | "he" | "uk" | "el" | "ms" | "cs" | "ro" | "da" | "hu" | "ta" | "no" | "th" | "ur" | "hr" | "bg" | "lt" | "la" | "mi" | "ml" | "cy" | "sk" | "te" | "fa" | "lv" | "bn" | "sr" | "az" | "sl" | "kn" | "et" | "mk" | "br" | "eu" | "is" | "hy" | "ne" | "mn" | "bs" | "kk" | "sq" | "sw" | "gl" | "mr" | "pa" | "si" | "km" | "sn" | "yo" | "so" | "af" | "oc" | "ka" | "be" | "tg" | "sd" | "gu" | "am" | "yi" | "lo" | "uz" | "fo" | "ht" | "ps" | "tk" | "nn" | "mt" | "sa" | "lb" | "my" | "bo" | "tl" | "mg" | "as" | "tt" | "haw" | "ln" | "ha" | "ba" | "jw" | "su" | "yue"

Parameters​

config​

WhisperSttModel<L>

The Whisper speech-to-text model configuration. See WhisperSttModel.

options?​

ResourceOptions

Load and caching options. See ResourceOptions.

Returns​

The same object as WhisperSpeechToText (without dispose), combined with loading state and download progress.

downloadProgress​

downloadProgress: number

Download progress across every asset, in percent.

error​

error: Error | undefined

The download or load error, if any.

isReady​

isReady: boolean

Whether the model is loaded and ready to transcribe.

resource​

resource: WhisperSttModel<L> | undefined

The config with every remote URL resolved to a local path.

stream​

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

streamInsert​

streamInsert: (audioChunk) => void | undefined

streamStop​

streamStop: () => void | undefined

transcribe​

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

transcribeStop​

transcribeStop: () => void | undefined

transcribeWorklet​

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

See​

WhisperSpeechToText

Call Signature​

useSpeechToText(config, options?): object

Defined in: hooks/useSpeechToText.ts:72

React hook to load and run a Qwen3-ASR speech-to-text model.

This hook manages downloading (if remote URLs are provided) and loading the model assets, tokenizer, and voice activity detector, tracking download progress and load errors, and releasing native memory when the component unmounts or the configuration changes.

For imperative usage, see createQwen3AsrSpeechToText.

Parameters​

config​

Qwen3AsrSttModel

The Qwen3-ASR model configuration. See Qwen3AsrSttModel.

options?​

ResourceOptions

Load and caching options. See ResourceOptions.

Returns​

The same object as Qwen3AsrSpeechToText (without dispose), combined with loading state and download progress.

downloadProgress​

downloadProgress: number

Download progress across every asset, in percent.

error​

error: Error | undefined

The download or load error, if any.

isReady​

isReady: boolean

Whether the model is loaded and ready to transcribe.

resource​

resource: Qwen3AsrSttModel | undefined

The config with every remote URL resolved to a local path.

stream​

stream: (options?) => AsyncGenerator<{ committed: string; nonCommitted: string; }> | undefined

streamInsert​

streamInsert: (audioChunk) => void | undefined

streamStop​

streamStop: () => void | undefined

transcribe​

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

transcribeStop​

transcribeStop: () => void | undefined

transcribeWorklet​

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

See​

Qwen3AsrSpeechToText

Call Signature​

useSpeechToText<L>(config, options?): object

Defined in: hooks/useSpeechToText.ts:105

React hook to load and run either speech-to-text pipeline, for callers that pick the model at runtime (e.g. from a list mixing Whisper and Qwen3-ASR).

Type Parameters​

L​

L extends "en" | "zh" | "de" | "es" | "ru" | "ko" | "fr" | "ja" | "pt" | "tr" | "pl" | "ca" | "nl" | "ar" | "sv" | "it" | "id" | "hi" | "fi" | "vi" | "he" | "uk" | "el" | "ms" | "cs" | "ro" | "da" | "hu" | "ta" | "no" | "th" | "ur" | "hr" | "bg" | "lt" | "la" | "mi" | "ml" | "cy" | "sk" | "te" | "fa" | "lv" | "bn" | "sr" | "az" | "sl" | "kn" | "et" | "mk" | "br" | "eu" | "is" | "hy" | "ne" | "mn" | "bs" | "kk" | "sq" | "sw" | "gl" | "mr" | "pa" | "si" | "km" | "sn" | "yo" | "so" | "af" | "oc" | "ka" | "be" | "tg" | "sd" | "gu" | "am" | "yi" | "lo" | "uz" | "fo" | "ht" | "ps" | "tk" | "nn" | "mt" | "sa" | "lb" | "my" | "bo" | "tl" | "mg" | "as" | "tt" | "haw" | "ln" | "ha" | "ba" | "jw" | "su" | "yue" = "en" | "zh" | "de" | "es" | "ru" | "ko" | "fr" | "ja" | "pt" | "tr" | "pl" | "ca" | "nl" | "ar" | "sv" | "it" | "id" | "hi" | "fi" | "vi" | "he" | "uk" | "el" | "ms" | "cs" | "ro" | "da" | "hu" | "ta" | "no" | "th" | "ur" | "hr" | "bg" | "lt" | "la" | "mi" | "ml" | "cy" | "sk" | "te" | "fa" | "lv" | "bn" | "sr" | "az" | "sl" | "kn" | "et" | "mk" | "br" | "eu" | "is" | "hy" | "ne" | "mn" | "bs" | "kk" | "sq" | "sw" | "gl" | "mr" | "pa" | "si" | "km" | "sn" | "yo" | "so" | "af" | "oc" | "ka" | "be" | "tg" | "sd" | "gu" | "am" | "yi" | "lo" | "uz" | "fo" | "ht" | "ps" | "tk" | "nn" | "mt" | "sa" | "lb" | "my" | "bo" | "tl" | "mg" | "as" | "tt" | "haw" | "ln" | "ha" | "ba" | "jw" | "su" | "yue"

Parameters​

config​

A Whisper or Qwen3-ASR model configuration.

Qwen3AsrSttModel | WhisperSttModel<L>

options?​

ResourceOptions

Load and caching options. See ResourceOptions.

Returns​

The runner of whichever pipeline config names, combined with loading state and download progress.

downloadProgress​

downloadProgress: number

Download progress across every asset, in percent.

error​

error: Error | undefined

The download or load error, if any.

isReady​

isReady: boolean

Whether the model is loaded and ready to transcribe.

resource​

resource: Qwen3AsrSttModel | WhisperSttModel<L> | undefined

The config with every remote URL resolved to a local path.

stream​

stream: (options?) => AsyncGenerator<{ committed: string; nonCommitted: string; }> | (options) => AsyncGenerator<{ committed: string; nonCommitted: string; }> | undefined

streamInsert​

streamInsert: (audioChunk) => void | (audioChunk) => void | undefined

streamStop​

streamStop: () => void | () => void | undefined

transcribe​

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

transcribeStop​

transcribeStop: () => void | () => void | undefined

transcribeWorklet​

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