Skip to main content

Overview

GenerationOptions controls all aspects of the speech synthesis pipeline, including sampling parameters, chunking strategy, and concurrency. All fields have sensible defaults, so the zero-argument initializer works for most use cases.

Initialization

Float
default:"0.9"
Sampling temperature. Higher values (e.g., 1.0) make output more random; lower values (e.g., 0.5) make it more deterministic.
Int
default:"50"
Top-K sampling parameter. Only the K most likely tokens are considered at each step.
Float
default:"1.05"
Repetition penalty to discourage repeating tokens. Values > 1.0 penalize repetition.
Int
default:"245"
Maximum number of tokens to generate in the autoregressive loop.
Int
default:"0"
Number of concurrent workers for multi-chunk generation:
  • 0: all chunks run concurrently in one batch (default, fastest for non-streaming use cases)
  • 1: sequential - one chunk at a time; required for real-time play streaming
  • N: at most N chunks run concurrently
TextChunkingStrategy?
default:"nil"
How to split long text into chunks. Defaults to .sentence. Set to .none to force a single-pass generation without sentence splitting.
Int?
default:"nil"
Target chunk size in tokens for sentence chunking. nil resolves to TextChunker.defaultTargetChunkSize at the call site.
Int?
default:"nil"
Minimum chunk size in tokens. nil resolves to TextChunker.defaultMinChunkSize at the call site.
String?
default:"nil"
Optional style instruction for controlling speech characteristics (e.g., "Very happy"). Prepended as a text-only user prompt before the main TTS segment. For Qwen3, this is only supported by the 1.7B model variant.
Bool
default:"false"
Force the legacy [FloatType] inference path even on macOS 15+ / iOS 18+. When false (default), the MLTensor path is taken on supported OS versions. Set to true in tests to exercise the pre-macOS-15 code path on current hardware.

Properties

Sampling Parameters

Float
Sampling temperature. Default: 0.9
Int
Top-K sampling parameter. Default: 50
Float
Repetition penalty to discourage repeating tokens. Default: 1.05
Int
Maximum number of tokens to generate. Default: 245

Chunking and Concurrency

Int
Number of concurrent workers for multi-chunk generation. Default: 0 (all chunks concurrently)
TextChunkingStrategy?
How to split long text into chunks. Default: nil (resolves to .sentence)
Int?
Target chunk size in tokens for sentence chunking. Default: nil (uses TextChunker.defaultTargetChunkSize)
Int?
Minimum chunk size in tokens. Default: nil (uses TextChunker.defaultMinChunkSize)

Style Control

String?
Optional style instruction for controlling speech characteristics. Default: nilOnly supported by the Qwen3 1.7B model variant.

Advanced

Bool
Force the legacy [FloatType] inference path. Default: false

Static Properties

defaultTemperature

Float
Default sampling temperature: 0.9

defaultTopK

Int
Default Top-K sampling parameter: 50

defaultRepetitionPenalty

Float
Default repetition penalty: 1.05

defaultMaxNewTokens

Int
Default maximum number of tokens to generate: 245

Example Usage

Default Options

Custom Sampling

Sequential Generation (for Streaming)

With Style Instruction (1.7B only)

Disable Chunking

Custom Chunk Sizes

Parallel Generation