Overview
TTSKitConfig is an open class that configures all aspects of a TTSKit instance, including model selection, paths, compute units, component overrides, and lifecycle flags. It follows the WhisperKit pattern of exposing configuration as a mutable class that can be subclassed for custom setups.
Initialization
Model variant that determines default versionDir, component variants, and tokenizer.
Local URL to the model repository directory. If
nil, models are downloaded from modelRepo on HuggingFace Hub.Base URL for downloading and caching models.
nil uses the Hub library’s default cache directory.HuggingFace repo ID for auto-downloading models.
HuggingFace repo ID or local folder path for the tokenizer (resolved from
model by default).HuggingFace API token for private repos (or set the
HF_TOKEN env var).HuggingFace Hub endpoint URL. Override to point at a regional mirror or an on-premise Hub instance.
Version directory shared across all components (resolved from
model by default).Code decoder quantization variant (resolved from
model by default).Multi-code decoder quantization variant (resolved from
model by default).Code embedder quantization variant (resolved from
model by default).Multi-code embedder quantization variant (resolved from
model by default).Text projector quantization variant (resolved from
model by default).Speech decoder quantization variant (resolved from
model by default).Compute unit configuration per model component.
Whether to emit diagnostic logs during loading and generation.
Logging level when
verbose is true.Specific git revision (commit SHA, tag, or branch) to download from the Hub.
nil (default) resolves to the repo’s default branch head.Additional glob patterns to include during model download, appended to the patterns generated from the configured component variants.
Use a background URLSession for model downloads.
Download models if not already available locally. When
true (default), loadModels() will trigger a download if modelFolder is nil.Enable model prewarming. Prewarming compiles each CoreML model sequentially then discards weights, minimizing peak memory during compilation.
Load models immediately after init.
nil loads when modelFolder is non-nil.Optional seed for reproducible generation. Each concurrent task receives a derived seed (
seed ^ taskIndex).Properties
Model Selection
Model variant that determines default versionDir, component variants, and tokenizer.
Model Location
Local URL to the model repository directory. If
nil, models are downloaded from modelRepo on HuggingFace Hub.Base URL for downloading and caching models.
nil uses the Hub library’s default cache directory.HuggingFace repo ID for auto-downloading models.
Tokenizer
HuggingFace repo ID or local folder path for the tokenizer (resolved from
model by default).Authentication
HuggingFace API token for private repos (or set the
HF_TOKEN env var).HuggingFace Hub endpoint URL.
Component Variants
Version directory shared across all components (resolved from
model by default).Per-component quantization variant for the code decoder.
Per-component quantization variant for the multi-code decoder.
Per-component quantization variant for the code embedder.
Per-component quantization variant for the multi-code embedder.
Per-component quantization variant for the text projector.
Per-component quantization variant for the speech decoder.
Compute
Compute unit configuration per model component.
Logging
Whether to emit diagnostic logs during loading and generation.
Logging level when
verbose is true. Defaults to .info.Download Options
Specific git revision (commit SHA, tag, or branch) to download from the Hub.
Additional glob patterns to include during model download.
Use a background URLSession for model downloads.
Download models if not already available locally.
Lifecycle Flags
Enable model prewarming.
Load models immediately after init.
nil loads when modelFolder is non-nil.Generation
Optional seed for reproducible generation.
Component Overrides
Custom text projector implementation.
nil means TTSKit will use the default Qwen3 TTS class.Custom code embedder implementation.
Custom multi-code embedder implementation.
Custom code decoder implementation.
Custom multi-code decoder implementation.
Custom speech decoder implementation.
Instance Methods
modelURL(component:variant:)
Resolve the full path to a component’s model bundle.Component name (e.g., “code_decoder”).
Variant name (e.g., “W8A16-stateful”).
URL to the component’s
.mlmodelc bundle, or nil if modelFolder is not set.modelFolder to be set (either directly or via download). Prefers a compiled .mlmodelc bundle and falls back to .mlpackage.
tokenizerSource
The effective tokenizer source: localtokenizerFolder if set, otherwise the model’s default HuggingFace repo ID.
Path or repo ID for the tokenizer.
componentDirectories(in:)
Version-specific directory for each component insidemodelFolder.
Base folder. Uses
modelFolder if nil.Array of component directory URLs. Empty if
modelFolder is not set.downloadPatterns
Glob patterns used to download only the files needed for the configured variants.Array of glob patterns for the six model components.
Static Properties
componentNames
Component names in the model layout.["text_projector", "code_embedder", "multi_code_embedder", "code_decoder", "multi_code_decoder", "speech_decoder"]Expected Directory Layout
When using local models, themodelFolder should contain the following structure: