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

# Inworld Blueprint Function Library

[Overview](./overview) > Inworld Blueprint Function Library

**Class:** `UInworldBlueprintFunctionLibrary` | **Inherits from:** `UBlueprintFunctionLibrary`

## Methods

* [BreakAudio](#breakaudio)
* [BuildPhoneSpansFromTTSOutput](#buildphonespansfromttsoutput)
* [CreateBooleanJinjaArgument](#createbooleanjinjaargument)
* [CreateFloatJinjaArgument](#createfloatjinjaargument)
* [CreateIntJinjaArgument](#createintjinjaargument)
* [CreateInworldDataError](#createinworlddataerror)
* [CreateStringJinjaArgument](#createstringjinjaargument)
* [CreateStructJinjaArgument](#createstructjinjaargument)
* [DataStreamTTSOutputGetNext](#datastreamttsoutputgetnext)
* [DataStreamTTSOutputHasNext](#datastreamttsoutputhasnext)
* [GetCurrentWord](#getcurrentword)
* [GetPhonemeBlends](#getphonemeblends)
* [GetPhonemeBlendsTTS](#getphonemeblendstts)
* [GetRuntimeStruct](#getruntimestruct)
* [GetVisemeBlends](#getvisemeblends)
* [GetVisemeBlendsTTS](#getvisemeblendstts)
* [MakeAudio](#makeaudio)
* [RenderJinjaWithArgMap](#renderjinjawithargmap)
* [RenderJinjaWithJson](#renderjinjawithjson)
* [TrimLLMOutput](#trimllmoutput)
* [UnwrapInworldDataHandle](#unwrapinworlddatahandle)
* [WrapInworldData](#wrapinworlddata)

## Reference

### BreakAudio

```c++ theme={"system"}
void BreakAudio(
    const FInworldData_Audio& Audio,
    TArray<uint8>& OutWaveform,
    int32& OutSampleRate
)
```

#### Parameters

| Parameter     | Type                        | Description                   |
| ------------- | --------------------------- | ----------------------------- |
| Audio         | `const FInworldData_Audio&` | The audio data to break apart |
| OutWaveform   | `TArray<uint8>&`            | The raw PCM waveform bytes    |
| OutSampleRate | `int32&`                    | The sample rate of the audio  |

***

### BuildPhoneSpansFromTTSOutput

Builds a flat array of phone spans from a TTS output object. Extracts phonetic timing data from `Timestamps → PhoneticDetails.Phones`. Use this to cache lip-sync data from a completed TTS output before playback.

```c++ theme={"system"}
void BuildPhoneSpansFromTTSOutput(
    const FInworldData_TTSOutput& TTSOutput,
    TArray<FInworldPhoneSpan>& OutPhoneSpans
)
```

#### Parameters

| Parameter     | Type                            | Description                                       |
| ------------- | ------------------------------- | ------------------------------------------------- |
| TTSOutput     | `const FInworldData_TTSOutput&` | The TTS output containing phonetic timestamp data |
| OutPhoneSpans | `TArray<FInworldPhoneSpan>&`    | The resulting flat array of phone spans           |

***

### CreateBooleanJinjaArgument

```c++ theme={"system"}
FJinjaArgument CreateBooleanJinjaArgument(bool Value)
```

#### Parameters

| Parameter | Type   | Description               |
| --------- | ------ | ------------------------- |
| Value     | `bool` | The boolean value to wrap |

#### Returns

**Type:** `FJinjaArgument`

***

### CreateFloatJinjaArgument

```c++ theme={"system"}
FJinjaArgument CreateFloatJinjaArgument(float Value)
```

#### Parameters

| Parameter | Type    | Description             |
| --------- | ------- | ----------------------- |
| Value     | `float` | The float value to wrap |

#### Returns

**Type:** `FJinjaArgument`

***

### CreateIntJinjaArgument

```c++ theme={"system"}
FJinjaArgument CreateIntJinjaArgument(int32 Value)
```

#### Parameters

| Parameter | Type    | Description               |
| --------- | ------- | ------------------------- |
| Value     | `int32` | The integer value to wrap |

#### Returns

**Type:** `FJinjaArgument`

***

### CreateInworldDataError

```c++ theme={"system"}
void CreateInworldDataError(
    UScriptStruct* InworldDataStructType,
    EInworldStatusCode StatusCode,
    const FString& Reason,
    int32& Data
)
```

#### Parameters

| Parameter             | Type                 | Description                               |
| --------------------- | -------------------- | ----------------------------------------- |
| InworldDataStructType | `UScriptStruct*`     | The struct type to wrap the error in      |
| StatusCode            | `EInworldStatusCode` | The status code indicating the error type |
| Reason                | `const FString&`     | Human-readable description of the error   |
| Data                  | `int32&`             | Output: the resulting error data handle   |

***

### CreateStringJinjaArgument

```c++ theme={"system"}
FJinjaArgument CreateStringJinjaArgument(FString Value)
```

#### Parameters

| Parameter | Type      | Description              |
| --------- | --------- | ------------------------ |
| Value     | `FString` | The string value to wrap |

#### Returns

**Type:** `FJinjaArgument`

***

### CreateStructJinjaArgument

```c++ theme={"system"}
FJinjaArgument CreateStructJinjaArgument(const int32& Data)
```

#### Parameters

| Parameter | Type           | Description                                               |
| --------- | -------------- | --------------------------------------------------------- |
| Data      | `const int32&` | The struct value to wrap (wildcard — accepts any USTRUCT) |

#### Returns

**Type:** `FJinjaArgument`

***

### DataStreamTTSOutputGetNext

Retrieves the next TTS output chunk from a streaming TTS data stream. Should only be called when `DataStreamTTSOutputHasNext` returns `true`.

```c++ theme={"system"}
FInworldDataHandle DataStreamTTSOutputGetNext(FInworldData_DataStream_TTSOutput TTSOutputStream)
```

#### Parameters

| Parameter       | Type                                | Description                      |
| --------------- | ----------------------------------- | -------------------------------- |
| TTSOutputStream | `FInworldData_DataStream_TTSOutput` | The TTS data stream to read from |

#### Returns

**Type:** `FInworldDataHandle`

***

### DataStreamTTSOutputHasNext

Returns whether a streaming TTS data stream has more output chunks available.

```c++ theme={"system"}
bool DataStreamTTSOutputHasNext(const FInworldData_DataStream_TTSOutput& TTSOutputStream)
```

#### Parameters

| Parameter       | Type                                       | Description                  |
| --------------- | ------------------------------------------ | ---------------------------- |
| TTSOutputStream | `const FInworldData_DataStream_TTSOutput&` | The TTS data stream to check |

#### Returns

**Type:** `bool`

***

### GetCurrentWord

Returns the word currently being spoken at the given playback position. Compares `PlaybackInfo.Utterance.PlayedDuration` against each word's `StartTime` and `EndTime` from the TTS output timestamps.

```c++ theme={"system"}
FInworldAudioVoiceWord GetCurrentWord(
    const FInworldVoiceAudioPlaybackInfo& PlaybackInfo,
    const FInworldData_TTSOutput& TTSOutput
)
```

#### Parameters

| Parameter    | Type                                    | Description                                        |
| ------------ | --------------------------------------- | -------------------------------------------------- |
| PlaybackInfo | `const FInworldVoiceAudioPlaybackInfo&` | Current playback state, including elapsed duration |
| TTSOutput    | `const FInworldData_TTSOutput&`         | The TTS output containing word timestamp data      |

#### Returns

**Type:** `FInworldAudioVoiceWord`

***

### GetPhonemeBlends

Calculates phoneme blend weights at the current playback position from a pre-built array of phone spans. Uses the same timing logic as `GetVisemeBlends` but returns phoneme codes instead of viseme categories. Use this when you need raw phoneme data rather than viseme mappings.

```c++ theme={"system"}
FInworldPhonemeBlends GetPhonemeBlends(
    const FInworldVoiceAudioPlaybackInfo& PlaybackInfo,
    const TArray<FInworldPhoneSpan>& PhoneSpans
)
```

#### Parameters

| Parameter    | Type                                    | Description                                                          |
| ------------ | --------------------------------------- | -------------------------------------------------------------------- |
| PlaybackInfo | `const FInworldVoiceAudioPlaybackInfo&` | Current playback state, including elapsed duration                   |
| PhoneSpans   | `const TArray<FInworldPhoneSpan>&`      | Pre-built array of phone spans (from `BuildPhoneSpansFromTTSOutput`) |

#### Returns

**Type:** `FInworldPhonemeBlends`

***

### GetPhonemeBlendsTTS

Calculates phoneme blend weights directly from a TTS output object and current playback position. Combines `BuildPhoneSpansFromTTSOutput` and `GetPhonemeBlends` in a single call. Use `GetPhonemeBlends` with a cached span array if performance is a concern.

```c++ theme={"system"}
FInworldPhonemeBlends GetPhonemeBlendsTTS(
    const FInworldVoiceAudioPlaybackInfo& PlaybackInfo,
    const FInworldData_TTSOutput& TTSOutput
)
```

#### Parameters

| Parameter    | Type                                    | Description                                        |
| ------------ | --------------------------------------- | -------------------------------------------------- |
| PlaybackInfo | `const FInworldVoiceAudioPlaybackInfo&` | Current playback state, including elapsed duration |
| TTSOutput    | `const FInworldData_TTSOutput&`         | The TTS output containing phonetic timestamp data  |

#### Returns

**Type:** `FInworldPhonemeBlends`

***

### GetRuntimeStruct

```c++ theme={"system"}
void GetRuntimeStruct(
    UInworldProcessContext* ProcessContext,
    const FName& Key,
    UScriptStruct* ScriptStruct,
    int32& Struct,
    bool& Successful
)
```

#### Parameters

| Parameter      | Type                      | Description                             |
| -------------- | ------------------------- | --------------------------------------- |
| ProcessContext | `UInworldProcessContext*` | The process context to read from        |
| Key            | `const FName&`            | The runtime data key to look up         |
| ScriptStruct   | `UScriptStruct*`          | The expected struct type                |
| Struct         | `int32&`                  | Output: the retrieved struct value      |
| Successful     | `bool&`                   | Output: whether the retrieval succeeded |

***

### GetVisemeBlends

Calculates viseme blend weights for the current playback position from a pre-built array of phone spans. Smoothly interpolates between visemes. Build `PhoneSpans` once per utterance using `BuildPhoneSpansFromTTSOutput` and cache it for use each tick.

```c++ theme={"system"}
FInworldVisemeBlends GetVisemeBlends(
    const FInworldVoiceAudioPlaybackInfo& PlaybackInfo,
    const TArray<FInworldPhoneSpan>& PhoneSpans
)
```

#### Parameters

| Parameter    | Type                                    | Description                                                          |
| ------------ | --------------------------------------- | -------------------------------------------------------------------- |
| PlaybackInfo | `const FInworldVoiceAudioPlaybackInfo&` | Current playback state, including elapsed duration                   |
| PhoneSpans   | `const TArray<FInworldPhoneSpan>&`      | Pre-built array of phone spans (from `BuildPhoneSpansFromTTSOutput`) |

#### Returns

**Type:** `FInworldVisemeBlends`

***

### GetVisemeBlendsTTS

Calculates viseme blend weights directly from a TTS output object and current playback position. Combines `BuildPhoneSpansFromTTSOutput` and `GetVisemeBlends` in a single call. Use `GetVisemeBlends` with a cached span array if performance is a concern.

```c++ theme={"system"}
FInworldVisemeBlends GetVisemeBlendsTTS(
    const FInworldVoiceAudioPlaybackInfo& PlaybackInfo,
    const FInworldData_TTSOutput& TTSOutput
)
```

#### Parameters

| Parameter    | Type                                    | Description                                        |
| ------------ | --------------------------------------- | -------------------------------------------------- |
| PlaybackInfo | `const FInworldVoiceAudioPlaybackInfo&` | Current playback state, including elapsed duration |
| TTSOutput    | `const FInworldData_TTSOutput&`         | The TTS output containing phonetic timestamp data  |

#### Returns

**Type:** `FInworldVisemeBlends`

***

### MakeAudio

```c++ theme={"system"}
FInworldData_Audio MakeAudio(
    const TArray<uint8>& Waveform,
    int32 SampleRate
)
```

#### Parameters

| Parameter  | Type                   | Description                   |
| ---------- | ---------------------- | ----------------------------- |
| Waveform   | `const TArray<uint8>&` | Raw PCM waveform bytes        |
| SampleRate | `int32`                | Sample rate of the audio data |

#### Returns

**Type:** `FInworldData_Audio`

***

### RenderJinjaWithArgMap

Renders a Jinja2 template string using a map of typed argument values. Returns `true` on success and writes the rendered output to `OutJinja`. Use `CreateBooleanJinjaArgument`, `CreateStringJinjaArgument`, etc. to build the argument map.

```c++ theme={"system"}
bool RenderJinjaWithArgMap(
    const FString& Template,
    const TMap<FString, FJinjaArgument>& ArgMap,
    FString& OutJinja
)
```

#### Parameters

| Parameter | Type                                   | Description                                    |
| --------- | -------------------------------------- | ---------------------------------------------- |
| Template  | `const FString&`                       | The Jinja2 template string                     |
| ArgMap    | `const TMap<FString, FJinjaArgument>&` | Map of variable names to typed argument values |
| OutJinja  | `FString&`                             | Output: the rendered string                    |

#### Returns

**Type:** `bool` — `true` if rendering succeeded

***

### RenderJinjaWithJson

Renders a Jinja2 template string using variables supplied as a JSON string. Returns `true` on success and writes the rendered output to `OutRender`.

```c++ theme={"system"}
bool RenderJinjaWithJson(
    const FString& JinjaTemplate,
    const FString& VariablesJson,
    FString& OutRender
)
```

#### Parameters

| Parameter     | Type             | Description                                                    |
| ------------- | ---------------- | -------------------------------------------------------------- |
| JinjaTemplate | `const FString&` | The Jinja2 template string                                     |
| VariablesJson | `const FString&` | A JSON object string whose keys map to template variable names |
| OutRender     | `FString&`       | Output: the rendered string                                    |

#### Returns

**Type:** `bool` — `true` if rendering succeeded

***

### TrimLLMOutput

Removes leading and trailing quotes as well as getting rid of double spaces and other artifacts of LLM text generation.

```c++ theme={"system"}
void TrimLLMOutput(
    const FString& LLMOutputString,
    FString& OutTrimmedLLMOutputString
)
```

#### Parameters

| Parameter                 | Type             | Description                                      |
| ------------------------- | ---------------- | ------------------------------------------------ |
| LLMOutputString           | `const FString&` | The LLM output string to edit                    |
| OutTrimmedLLMOutputString | `FString&`       | The result string with spaces and quotes removed |

***

### UnwrapInworldDataHandle

```c++ theme={"system"}
void UnwrapInworldDataHandle(
    const FInworldDataHandle& DataHandle,
    UScriptStruct* ScriptStruct,
    int32& Data,
    bool& UnwrapSuccessful
)
```

#### Parameters

| Parameter        | Type                        | Description                          |
| ---------------- | --------------------------- | ------------------------------------ |
| DataHandle       | `const FInworldDataHandle&` | The data handle to unwrap            |
| ScriptStruct     | `UScriptStruct*`            | The expected struct type             |
| Data             | `int32&`                    | Output: the unwrapped struct value   |
| UnwrapSuccessful | `bool&`                     | Output: whether the unwrap succeeded |

***

### WrapInworldData

```c++ theme={"system"}
FInworldDataHandle WrapInworldData(
    UScriptStruct* ScriptStruct,
    const int32& Data
)
```

#### Parameters

| Parameter    | Type             | Description                                               |
| ------------ | ---------------- | --------------------------------------------------------- |
| ScriptStruct | `UScriptStruct*` | The struct type of the data to wrap                       |
| Data         | `const int32&`   | The struct value to wrap (wildcard — accepts any USTRUCT) |

#### Returns

**Type:** `FInworldDataHandle`
