Skip to main content
Version: Next

Function: useTextToSpeech()

Call Signature

useTextToSpeech<K>(config, options?): object

Defined in: hooks/useTextToSpeech.ts:31

React hook to load and run the Kokoro Text-to-Speech pipeline.

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

For imperative usage, see createKokoroTextToSpeech.

Type Parameters

K

K extends PropertyKey

Voice keys record constraint.

Parameters

config

KokoroTtsModel<K>

The Kokoro TTS model configuration. See KokoroTtsModel.

options?

ResourceOptions

Load and caching options. See ResourceOptions.

Returns

The same object as KokoroTextToSpeech (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 pipeline is loaded and ready to synthesize.

resource

resource: KokoroTtsModel<K> | undefined

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

synthesize

synthesize: (text, options) => AsyncGenerator<KokoroTtsChunk> | undefined

Streams synthesized audio chunks. Undefined until the pipeline is ready.

synthesizeStop

synthesizeStop: () => void | undefined

Cancels an in-flight synthesis. Undefined until the pipeline is ready.

See

KokoroTextToSpeech

Call Signature

useTextToSpeech<K>(config, options?): object

Defined in: hooks/useTextToSpeech.ts:67

React hook to load and run the Supertonic 3 Text-to-Speech pipeline.

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

For imperative usage, see createSupertonicTextToSpeech.

Type Parameters

K

K extends PropertyKey

Voice style keys record constraint.

Parameters

config

SupertonicTtsModel<K>

The Supertonic TTS model configuration. See SupertonicTtsModel.

options?

ResourceOptions

Load and caching options. See ResourceOptions.

Returns

The same object as SupertonicTextToSpeech (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 pipeline is loaded and ready to synthesize.

resource

resource: SupertonicTtsModel<K> | undefined

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

synthesize

synthesize: (text, options) => AsyncGenerator<SupertonicTtsChunk> | undefined

Streams synthesized audio chunks. Undefined until the pipeline is ready.

synthesizeStop

synthesizeStop: () => void | undefined

Cancels an in-flight synthesis. Undefined until the pipeline is ready.

See

SupertonicTextToSpeech