> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gradium.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Voice Settings

> Fine-tune TTS output: speed, temperature, rewrite rules

TTS models accept advanced options via the `json_config` parameter. In
the Python SDK, this is a dict mapping option name to value (float or
string). For REST POST requests, pass it as an object in the JSON body.

These options apply to both the [WebSocket](https://docs.gradium.ai/guides/text-to-speech.md) and
[REST](https://docs.gradium.ai/guides/text-to-speech-rest.md) transports. For STT, see
[Transcription Settings](https://docs.gradium.ai/guides/transcription-settings.md).

**Deprecated: `cfg_coef` for TTS**

The new TTS model accepts `cfg_coef` in `json_config` but ignores its value. Remove it
from TTS requests. Voice Design's `cfg_scale` is a separate generation setting
and remains available.

## Quick reference

**Range** is the span each option is tuned and tested across.

| Parameter | Range | Default | Effect |
| - | - | - | - |
| `temp` | `0.0`–`1.4` | `0.7` | Sampling temperature. `0.0` is deterministic; higher values produce more diverse output. |
| `padding_bonus` | `-4.0`–`4.0` | `0.0` | Speech speed. Negative values are faster, positive values are slower. |
| `rewrite_rules` | string | voice language | Text-rewriting rules applied before synthesis. Defaults to the voice's language; pass `"none"` to disable. See [Text Rewriting Rules](https://docs.gradium.ai/guides/text-rewriting.md). |
| `no_resampling_delay` | boolean | `true` | Drops the 40 ms of silence that resampling adds at the start of a stream in a resampled output format. Set to `false` to restore it. See [Resampling delay](#resampling-delay). |

> [!NOTE]
>
> Validation accepts a wider span than the table: `temp` to `1.5`,
> `padding_bonus` from `-5.0` to `5.0`. Use the table's ranges when tuning.

For deterministic output, set `temp` to `0.0`. For multi-utterance
flows on a single session, see [Multiplexing](https://docs.gradium.ai/guides/multiplexing.md).
For designed voices, see also
[Voice Design settings](https://docs.gradium.ai/guides/voices/voice-design.md#synthesis-settings).
The TTS engine recognises the `<flush>` and `<break time="..." />`
tags described in [Text-to-Speech](https://docs.gradium.ai/guides/text-to-speech.md).

## Setup fields, not `json_config`

Two per-request options are set at the top level of the setup message,
alongside `voice_id`, rather than inside `json_config`:

| Field | Type | Effect |
| - | - | - |
| `pronunciation_id` | string | A pronunciation dictionary ID, applied for the whole session. See [Pronunciations](https://docs.gradium.ai/api-reference/endpoint/list-pronunciations.md). |
| `model_name` | string | Model alias to synthesise with. Defaults to `default`. See [Model selection](https://docs.gradium.ai/guides/text-to-speech.md#model-selection). |

`pronunciation_id` goes next to `voice_id`, at the top level of the
setup. An ID that doesn't exist is reported as `Pronunciation dictionary <id> not found.`

> [!NOTE]
>
> Pronunciation dictionaries apply to WebSocket sessions only. REST
> requests cannot use them; the pattern-based `rewrite_rules` in
> `json_config` are the only rewriting control there. See [Text
> Rewriting Rules](https://docs.gradium.ai/guides/text-rewriting.md).

```python theme={null}
# pronunciation_id sits beside voice_id; tuning options go in json_config.
audio = await client.tts(
    setup={
        "voice_id": "YTpq7expH9539ERJ",
        "output_format": "wav",
        "pronunciation_id": "bb1ckYhNHCcIJjdK",
        "json_config": {"temp": 0.3},
    },
    text="Our SDK ships today.",
)
```

## Speed control

You can guide the speed of the model using the padding bonus
parameter. Default value is 0.0. Negative values mean that the speaker
will speak faster (values between -4.0 and -0.1). Positive values mean
that the speaker will speak slower (values between 0.1 and 4.0).

```python theme={null}
sample_text = "Hello, this is a test from the Gradium Text to Speech system. We are testing the speed."

slower_audio = await client.tts(
    setup={'voice_id': 'YTpq7expH9539ERJ', 'output_format': 'wav', 'json_config':{'padding_bonus':2.0}},
    text=sample_text,
)

faster_audio = await client.tts(
    setup={'voice_id': 'YTpq7expH9539ERJ', 'output_format': 'wav', 'json_config':{'padding_bonus':-2.0}},
    text=sample_text,
)
```

## Temperature control

The temperature for the generation can be set with values ranging from
0 to 1.4. A value of 0 corresponds to a deterministic generation, while
higher values lead to more diverse outputs. Default value is 0.7.

```python theme={null}
setup = {'voice_id': 'YTpq7expH9539ERJ', 'output_format': 'wav', 'json_config':{'temp':0.3}}

audio = await client.tts(text=sample_text, setup=setup)
```

## Resampling delay

The model generates audio at 48 kHz. In a resampled output format (`pcm_8000`, `pcm_16000`, `pcm_22050`, `pcm_24000`, `pcm_44100`, `ulaw_8000` and `alaw_8000`) the stream used to start with 40 ms of silence added by the resampler. `no_resampling_delay` is `true` by default, which drops that silence: the first audio chunk then holds 40 ms instead of 80 ms, so use the `start_s` and `stop_s` timestamps rather than a fixed chunk size. `pcm`, `pcm_48000`, `wav` and `opus` are not resampled and are unaffected.

Set it to `false` to restore the leading silence and a fixed 80 ms first chunk:

```python theme={null}
setup = {'voice_id': 'Bla6SbVMczYnOhfK', 'output_format': 'pcm_16000', 'json_config': {'no_resampling_delay': False}}

audio = await client.tts(text=sample_text, setup=setup)
```

## Rewrite rules

The `rewrite_rules` parameter can be used to pass text rewriting rules
that are applied before the text is synthesized. The rules should be
passed as a string. More details on the rules themselves can be found
in the [Text Rewriting Rules](https://docs.gradium.ai/guides/text-rewriting.md) guide. Values
such as `"en"`, `"fr"`, `"fr-be"`, `"fr-ch"`, `"de"`, `"es"`, `"pt"`
enable all the rewriting rules for a given language or locale. When the voice has a language, its
rules are enabled by default; pass `"none"` to disable rewriting entirely.

## Passing `json_config`

```python theme={null}
config = {"temp": 0.3, "padding_bonus": -1.0}

# Streaming over WebSocket: setup is keyword args; json_config stays nested.
async with client.tts_realtime(
    voice_id="YTpq7expH9539ERJ",
    output_format="pcm",
    json_config=config,
) as stream:
    ...

# One-shot via SDK: setup is a dict containing json_config.
audio = await client.tts(
    setup={"voice_id": "YTpq7expH9539ERJ", "output_format": "wav", "json_config": config},
    text="Hello",
)
```

For REST, see the [TTS POST reference](https://docs.gradium.ai/api-reference/endpoint/tts-post.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.