---
related_nodes: ["generate_speech", "audio_join", "upload_media", "split_text"]
---

# Inworld TTS

Synthesizes speech with Inworld's own text-to-speech controls in one synchronous request, and
returns the audio as binary together with the provider's usage and alignment metadata.

`Generate Speech` remains the portable surface: one text field, one voice, the same shape for every
speech provider. Use this node instead when you need Inworld's own controls — delivery mode,
speaking direction, word or character timestamps, the documented audio matrix, or preceding text as
prosody context — without a raw HTTP node and a hand-written base64 decoder downstream.

## What It Does

The node resolves the configured Inworld connection and speech model, interpolates the text, voice,
instruction, language, and context templates, and performs exactly one `POST /tts/v1/voice`. The
returned `audioContent` is decoded inside the node: the base64 envelope never becomes workflow data.
The `output` socket carries decoded binary audio plus the provider's `usage` and `timestampInfo`
when they are returned.

Key capabilities:
- **Native controls**: delivery mode, temperature, request-level instruction, language, text
  normalization, audio enhancement
- **Audio matrix**: MP3, Ogg Opus, WAV, Linear16, raw PCM, FLAC, A-law, µ-law with the sample rate,
  bit rate, and speaking rate each encoding supports
- **Alignment metadata**: word or character timestamps, including phonetic and viseme detail
- **Prosody context**: ordered preceding text, authored as rows or taken from an input reference
- **Binary output**: decoded audio bytes with a content type and filename matching the encoding

## When to Use

- Long scripts split into sections that must sound continuous, using the previous section as context
- Narration where the speaking direction changes per request
- Audio that must be captioned or lip-synced from word or character timestamps
- Output formats the portable node does not expose, such as FLAC or telephony A-law

Use `Generate Speech` for a single short utterance with default settings, or when the workflow
should keep working if you switch to a different speech provider.

## How It Works

1. **Deadline**: one budget is taken from `timeout_secs`, capped by the remaining workflow deadline,
   and covers credential resolution, the request, and decoding
2. **Interpolation**: text, voice, instruction, language, and context templates are resolved against
   the `input` socket
3. **Model resolution**: the connection and model are resolved as an Inworld speech generator with an
   API-key connection
4. **Request validation**: character limits, temperature, and the audio combination are checked
   before any network call
5. **Single attempt**: one `POST /tts/v1/voice`. The request is never retried and redirects are not
   followed
6. **Decoding**: `audioContent` is base64-decoded into binary, and the content type and filename are
   taken from the selected encoding
7. **Downstream flow**: `Audio Join` to assemble sections, `Upload Media` to persist the file

## Inputs

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `input` | any | Yes | Value the text, voice, instruction, language, and context templates interpolate against |

## Configuration

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `model` | model | Yes | Inworld connection and speech model. Only Inworld connections are offered |
| `voice_id` | model voice | Yes | Voice from the selected model, or a private voice ID or template |
| `text` | text | Yes | Text to speak. Defaults to `{{ input }}`. At most 2,000 characters |
| `instruction` | text | No | Speaking direction for this request |
| `language` | text | No | Provider language tag, such as `EN_GB` |
| `delivery_mode` | enum | No | `DELIVERY_MODE_UNSPECIFIED`, `STABLE`, `BALANCED`, `CREATIVE` |
| `temperature` | number | No | 0 to 2, where `0` requests the provider default of 1 |
| `timestamp_type` | enum | No | `TIMESTAMP_TYPE_UNSPECIFIED`, `WORD`, `CHARACTER` |
| `apply_text_normalization` | enum | No | `APPLY_TEXT_NORMALIZATION_UNSPECIFIED`, `ON`, `OFF` |
| `enhance_generation` | boolean | No | Provider audio enhancement. Provider default is off |
| `audio_config` | union on `audioEncoding` | No | Output encoding and its rates. Unset uses provider defaults |
| `synthesis_context` | union on `source` | No | Ordered preceding text used to steer prosody |
| `timeout_secs` | integer | No | Deadline for the single attempt. Defaults to `120`, must be above zero |

Text fields are template blocks: `{ "content": "...", "mode": "template" }`, or `"mode": "raw"` to
send the text exactly as written. `voice_id` is also templatable, so a runtime reference such as
`{{ input.voiceId }}` is accepted where the picker offers a list.

`model` is `{ "connection_id": "...", "model_id": "inworld-tts-2" }`.

### Settings a model ignores

The node sends what you configure and does not second-guess the model. Inworld decides what to read:

- `temperature` is ignored by `inworld-tts-2`. It is still accepted and sent, so a value carried
  over from another model stays visible rather than being silently dropped.
- `delivery_mode` and `instruction` are read by `inworld-tts-2` and ignored by older models.
- `DELIVERY_MODE_UNSPECIFIED` means `BALANCED`.
- Inline tags in the text override `instruction`.

### Audio encodings

`audio_config` is chosen by `audioEncoding`, and each encoding exposes only the fields it supports.
Leaving `audio_config` unset uses the provider defaults: MP3, 48,000 Hz, 128,000 bps, speed 1.

| `audioEncoding` | `sampleRateHertz` | `bitRate` | Output |
|---|---|---|---|
| `MP3` | 16000, 22050, 24000, 32000, 44100, 48000 | 32000-320000 | `audio/mpeg`, `speech.mp3` |
| `OGG_OPUS` | 8000-48000 from the common set | 32000-192000 | `audio/ogg`, `speech.ogg` |
| `WAV` | common set | — | `audio/wav`, `speech.wav` |
| `LINEAR16` | common set | — | `audio/wav`, `speech.wav` |
| `PCM` | common set | — | `audio/pcm`, `speech.pcm` |
| `FLAC` | common set | — | `audio/flac`, `speech.flac` |
| `ALAW` | 8000 only | — | `audio/PCMA`, `speech.alaw` |
| `MULAW` | 8000 only | — | `audio/PCMU`, `speech.mulaw` |

The common sample-rate set is 8000, 16000, 22050, 24000, 32000, 44100, and 48000. MP3 excludes 8000;
A-law and µ-law require 8000. `bitRate` exists only for the two compressed encodings, and a bit rate
set on any other encoding is refused rather than ignored. `speakingRate` is available on every
encoding and must be between 0.5 and 1.5.

**Only MP3, WAV, and Ogg output can be joined by `Audio Join`.** FLAC, raw PCM, A-law, and µ-law are
valid synthesis outputs but cannot be concatenated, so pick MP3, WAV, or Ogg for a script that is
spoken in sections and assembled into one file.

### Synthesis context

Preceding text steers prosody so consecutive sections sound continuous. It is never synthesized and
is not billed. The combined text of all `previousRequests` rows is limited to 2,000 characters, the
same limit as `text`.

Two sources, both reduced to `synthesisContext.previousRequests` on the wire:

- `"source": "configured"` — `previous_requests` is an ordered list of `{ "text": <template> }`
  rows, oldest first, each interpolated independently.
- `"source": "input"` — `previous_requests` is a single reference, such as
  `{{ input.previousRequests }}`, that must resolve to an array of `{"text": "..."}` objects. An
  empty array is valid. A null, a stringified JSON blob, or a row of the wrong shape fails the run
  with the field path, so a section is never spoken without the context it was supposed to carry.

This is a typed list source, not a raw request-body editor: nothing else can be injected into the
request from it.

## Output

| Name | Type | Description |
|------|------|-------------|
| `output` | object | Decoded audio with the provider's usage and alignment metadata |

```json
{
  "audio": {
    "binary": { "__binary__": true },
    "filename": "speech.mp3",
    "content_type": "audio/mpeg"
  },
  "usage": {
    "processedCharactersCount": 58,
    "modelId": "inworld-tts-2"
  },
  "timestampInfo": {
    "wordAlignment": {
      "words": ["The", "market", "opened", "quietly."],
      "wordStartTimeSeconds": [0.12, 0.31, 0.72, 1.04],
      "wordEndTimeSeconds": [0.30, 0.71, 1.03, 1.68],
      "phoneticDetails": [
        {
          "wordIndex": 0,
          "phones": [
            { "phoneSymbol": "DH", "startTimeSeconds": 0.12, "durationSeconds": 0.06, "visemeSymbol": "TH" }
          ]
        }
      ]
    }
  },
  "status": 200
}
```

- `audio` is always present, and takes `Audio Join`, `Upload Media`, and `Discord Action`
  attachments directly.
- `usage` is present when the provider reports it.
- `timestampInfo` is present only when `timestamp_type` requested alignment. `wordAlignment` carries
  `phoneticDetails` when the provider returns them; `characterAlignment` carries `characters`,
  `characterStartTimeSeconds`, and `characterEndTimeSeconds`.
- `status` is the HTTP status of the single attempt, always `200` on success.

Inside a `Loop`, add a one-line `JS Script` leaf after this node — `return inputs.input.audio;` — so
the collected item is the clip that `Audio Join` expects.

## Examples

### Two-segment narration with context

A script spoken in two sections, where the second section is given the first as context so the
prosody carries across the join. `<break>` markup counts toward the 2,000-character limit like any
other text.

Segment one:

```json
{
  "model": { "connection_id": "01J0EXAMPLECONNECTION0000", "model_id": "inworld-tts-2" },
  "voice_id": "test-voice-placeholder",
  "text": {
    "content": "<break time=\"500ms\" /> The market opened quietly.",
    "mode": "raw"
  },
  "instruction": {
    "content": "Read as a clear, neutral financial narrator.",
    "mode": "raw"
  },
  "delivery_mode": "BALANCED",
  "audio_config": {
    "audioEncoding": "MP3",
    "sampleRateHertz": 44100,
    "bitRate": 128000,
    "speakingRate": 1.0
  },
  "timeout_secs": 120
}
```

Segment two names segment one as its only predecessor:

```json
{
  "model": { "connection_id": "01J0EXAMPLECONNECTION0000", "model_id": "inworld-tts-2" },
  "voice_id": "test-voice-placeholder",
  "text": {
    "content": "The analyst's note says \"watch cash flow\" — not just earnings.",
    "mode": "raw"
  },
  "instruction": {
    "content": "Read as a clear, neutral financial narrator.",
    "mode": "raw"
  },
  "delivery_mode": "BALANCED",
  "synthesis_context": {
    "source": "configured",
    "previous_requests": [
      {
        "text": {
          "content": "<break time=\"500ms\" /> The market opened quietly.",
          "mode": "raw"
        }
      }
    ]
  },
  "audio_config": {
    "audioEncoding": "MP3",
    "sampleRateHertz": 44100,
    "bitRate": 128000,
    "speakingRate": 1.0
  },
  "timeout_secs": 120
}
```

Note that the predecessor is the previous section's own text, without the lead-in pause repeated as
audible silence: context steers prosody, it is not spoken.

### Long script assembled into one file

A step ahead of the loop emits `{ text, instruction, previousRequests }` per section, so the node
reads the context straight from its input:

```text
Constant(script)
  -> Split Text(max_chars = 1850)
  -> JS Script(build sections with previousRequests)
  -> Loop
       -> Inworld TTS(synthesis_context.source = "input")
       -> JS Script("return inputs.input.audio;")
  -> Audio Join(gap_ms = 250)
  -> Upload Media(kind_hint = audio)
```

The `input` context source expects the array itself, so pass `{{ input.previousRequests }}` as a
whole-field reference. Serializing it to a JSON string first is refused.

### Captions from word timestamps

```text
Manual Trigger
  -> Inworld TTS(timestamp_type = "WORD")
  -> JS Script(build cue list from output.timestampInfo.wordAlignment)
```

## Limits

- `text` is at most 2,000 characters, counted as characters and not bytes, including SSML markup and
  whitespace. Split a longer script with `Split Text` and join the clips.
- The combined text of all `previousRequests` rows is at most 2,000 characters.
- `temperature` is 0 to 2, `speakingRate` is 0.5 to 1.5, and each encoding's sample and bit rates are
  as listed above.
- `timeout_secs` must be above zero, and is capped by the workflow's own remaining deadline.

## Not part of this node

Streaming, asynchronous, and batch synthesis are separate Inworld operations and are not settings
here, nor are SSML parsing options or streaming timestamp transport. This node performs the one
synchronous voice request.

## When it refuses

Every failure is a single attempt: the request is never retried, so a timeout, a rate limit, or a
provider error costs one call and stops the run. Messages are prefixed `Inworld TTS [<class>]` and
carry the provider's status, error code, and a bounded, credential-stripped message.

| Class | Cause | What to change |
|---|---|---|
| `invalid_configuration` | Missing connection, non-Inworld connection, a model that is not an Inworld speech model, a non-API-key connection, empty voice or text, or an out-of-range number or encoding combination | Fix the named field. Save-time validation reports most of these before a run |
| `provider_validation` | Inworld rejected the request (400, 404, 422), including an unknown or inaccessible voice | Check the voice ID and language tag against the connection |
| `authentication` | The connection's API key was rejected (401) | Reconnect the Inworld connection |
| `authorization` | The key lacks access to the voice or model (403) | Use a voice and model the connection may use |
| `rate_limited` | Inworld returned 429 | Space out the requests; add `Sleep` in the loop |
| `upstream` | Inworld returned a 5xx | Retry the run later |
| `unexpected_status` | Any other non-200 response, including a redirect | Check the connection's base URL |
| `transport` | The request never reached Inworld | Check network access to the connection |
| `timeout` | The attempt exceeded `timeout_secs`, or the workflow deadline had already elapsed | Raise `timeout_secs`, shorten the section, or raise the workflow timeout |
| `cancelled` | The run was cancelled | Nothing; the in-flight request is dropped |
| `malformed_response` | The response was not the documented JSON | Retry the run |
| `missing_audio_content` | The response carried no `audioContent` | Retry the run |
| `invalid_audio_content` | `audioContent` was empty, not a string, or not valid base64 | Retry the run |

A private voice is accepted even when it is not in the picker's list: voice IDs are opaque to the
node, and only Inworld decides whether the connection may use one.
