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
TTSModelVariant
default:".qwen3TTS_0_6b"
Model variant that determines default versionDir, component variants, and tokenizer.
URL?
default:"nil"
Local URL to the model repository directory. If
nil, models are downloaded from modelRepo on HuggingFace Hub.URL?
default:"nil"
Base URL for downloading and caching models.
nil uses the Hub library’s default cache directory.String
default:"Qwen3TTSConstants.defaultModelRepo"
HuggingFace repo ID for auto-downloading models.
URL?
default:"nil"
HuggingFace repo ID or local folder path for the tokenizer (resolved from
model by default).String?
default:"nil"
HuggingFace API token for private repos (or set the
HF_TOKEN env var).String
default:"Qwen3TTSConstants.defaultEndpoint"
HuggingFace Hub endpoint URL. Override to point at a regional mirror or an on-premise Hub instance.
String?
default:"nil"
Version directory shared across all components (resolved from
model by default).String?
default:"nil"
Code decoder quantization variant (resolved from
model by default).String?
default:"nil"
Multi-code decoder quantization variant (resolved from
model by default).String?
default:"nil"
Code embedder quantization variant (resolved from
model by default).String?
default:"nil"
Multi-code embedder quantization variant (resolved from
model by default).String?
default:"nil"
Text projector quantization variant (resolved from
model by default).String?
default:"nil"
Speech decoder quantization variant (resolved from
model by default).ComputeOptions
default:"ComputeOptions()"
Compute unit configuration per model component.
Bool
default:"true"
Whether to emit diagnostic logs during loading and generation.
Logging.LogLevel
default:".info"
Logging level when
verbose is true.String?
default:"nil"
Specific git revision (commit SHA, tag, or branch) to download from the Hub.
nil (default) resolves to the repo’s default branch head.[String]
default:"[]"
Additional glob patterns to include during model download, appended to the patterns generated from the configured component variants.
Bool
default:"false"
Use a background URLSession for model downloads.
Bool
default:"true"
Download models if not already available locally. When
true (default), loadModels() will trigger a download if modelFolder is nil.Bool?
default:"nil"
Enable model prewarming. Prewarming compiles each CoreML model sequentially then discards weights, minimizing peak memory during compilation.
Bool?
default:"nil"
Load models immediately after init.
nil loads when modelFolder is non-nil.UInt64?
default:"nil"
Optional seed for reproducible generation. Each concurrent task receives a derived seed (
seed ^ taskIndex).Properties
Model Selection
TTSModelVariant
Model variant that determines default versionDir, component variants, and tokenizer.
Model Location
URL?
Local URL to the model repository directory. If
nil, models are downloaded from modelRepo on HuggingFace Hub.URL?
Base URL for downloading and caching models.
nil uses the Hub library’s default cache directory.String
HuggingFace repo ID for auto-downloading models.
Tokenizer
URL?
HuggingFace repo ID or local folder path for the tokenizer (resolved from
model by default).Authentication
String?
HuggingFace API token for private repos (or set the
HF_TOKEN env var).String
HuggingFace Hub endpoint URL.
Component Variants
String
Version directory shared across all components (resolved from
model by default).String
Per-component quantization variant for the code decoder.
String
Per-component quantization variant for the multi-code decoder.
String
Per-component quantization variant for the code embedder.
String
Per-component quantization variant for the multi-code embedder.
String
Per-component quantization variant for the text projector.
String
Per-component quantization variant for the speech decoder.
Compute
ComputeOptions
Compute unit configuration per model component.
Logging
Bool
Whether to emit diagnostic logs during loading and generation.
Logging.LogLevel
Logging level when
verbose is true. Defaults to .info.Download Options
String?
Specific git revision (commit SHA, tag, or branch) to download from the Hub.
[String]
Additional glob patterns to include during model download.
Bool
Use a background URLSession for model downloads.
Bool
Download models if not already available locally.
Lifecycle Flags
Bool?
Enable model prewarming.
Bool?
Load models immediately after init.
nil loads when modelFolder is non-nil.Generation
UInt64?
Optional seed for reproducible generation.
Component Overrides
(any TextProjecting)?
Custom text projector implementation.
nil means TTSKit will use the default Qwen3 TTS class.(any CodeEmbedding)?
Custom code embedder implementation.
(any MultiCodeEmbedding)?
Custom multi-code embedder implementation.
(any CodeDecoding)?
Custom code decoder implementation.
(any MultiCodeDecoding)?
Custom multi-code decoder implementation.
(any SpeechDecoding)?
Custom speech decoder implementation.
Instance Methods
modelURL(component:variant:)
Resolve the full path to a component’s model bundle.String
required
Component name (e.g., “code_decoder”).
String
required
Variant name (e.g., “W8A16-stateful”).
URL?
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.
String
Path or repo ID for the tokenizer.
componentDirectories(in:)
Version-specific directory for each component insidemodelFolder.
URL?
default:"nil"
Base folder. Uses
modelFolder if nil.[URL]
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.[String]
Array of glob patterns for the six model components.
Static Properties
componentNames
Component names in the model layout.[String]
["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: