Skip to main content
Version: Next

Function: useSpeechToText()

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

Defined in: hooks/useSpeechToText.ts:26

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​

object

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

downloadProgress​

downloadProgress: any

error​

error: any

isReady​

isReady: boolean = !!model

resource​

resource: any

stream​

stream: any = model.stream

streamInsert​

streamInsert: any = model.streamInsert

streamStop​

streamStop: any = model.streamStop

transcribe​

transcribe: any = model.transcribe

transcribeStop​

transcribeStop: any = model.transcribeStop

transcribeWorklet​

transcribeWorklet: any = model.transcribeWorklet

See​

WhisperSpeechToText