> For the complete documentation index, see [llms.txt](https://docs.borndigital.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.borndigital.ai/for-advanced-users/conversation-design-tips/customizing-speech-synthesis/variables-in-speech.md).

# Variables in speech

Use variables in the Speech text and avoid common problems.

Variables let the voicebot say values that are known only during the conversation – the customer's name, an order number or a date.

## General use

1. Make sure the variable has a value before the node is reached – for example set by a tool, an entity of an Answer node or a Function node.
2. In the **Speech** text of the [Message node](https://docs.borndigital.ai/digital-agent/conversation-flow/nodes-explained/message-node.md), type `{` or click the `{x}` icon and choose the variable, for example:

```
Thank you, {customer_name}. Your order {order_id} will arrive on {delivery_date}.
```

3. During the conversation, the value of the variable is put into the text before it is sent to speech synthesis – so the rules for [numbers, dates and pronunciation](https://docs.borndigital.ai/for-advanced-users/conversation-design-tips/customizing-speech-synthesis/numbers-dates-and-pronunciation.md) apply to the value, too. If the value is not in a form that reads well (for example a long ID without separators), prepare a separate variable for speech, for example with spaces or commas between the digit groups.

## Common problems and FAQ

<details>

<summary><span data-gb-custom-inline data-tag="emoji" data-code="1f92f">🤯</span> Why does the neural voice in Azure Audio Content Creator tool spell out every variable as <em>left curly bracket [...] right curly bracket</em>?</summary>

In Azure Speech Studio's Audio Content Creator, modifying the intonation on the pronunciation of variables in text-to-speech (TTS) output can be challenging due to the following:

* **The audio content creator tool is not connected to your database, so variables are not filled with values, therefore your variable names are considered as common words.** Reading out the literal characters occurs when text-to-speech encounters special characters, such as curly brackets, which are often used in programming languages.
* Dynamic nature of variables: Variables can hold a wide range of values, including names, numbers, or user-generated input. Each variable may require unique intonation patterns or pronunciation rules, making it challenging to create a one-size-fits-all approach within the TTS system.
* Lack of context awareness: Text-to-speech engines typically treat variables as plain text and lack the contextual understanding of the variable's meaning. As a result, it becomes difficult to apply nuanced intonation or pronunciation adjustments specifically to variable content.
* Limited SSML support for variable manipulation: While SSML (Speech Synthesis Markup Language) provides a range of tags and attributes to control TTS output, it may have limited support for manipulating variables. SSML tags are primarily designed to modify the speech synthesis process and don't always provide direct control over variable pronunciation or intonation.
* Pre-trained voice limitations: In some cases, if the TTS output is based on pre-recorded voice samples, modifying the intonation or pronunciation of variables may not be feasible as the pre-recorded voice may not have the necessary flexibility to handle variable-specific modifications.

Addressing these challenges often requires a deeper level of customization and integration within the TTS system. It may involve leveraging advanced techniques like custom voice models, data-driven synthesis, or **employing specific programming logic to manipulate variable-specific intonation patterns.**

</details>

<details>

<summary>Why can't I use the &#x3C;sub alias> SSML tag on a part of the speech with a variable in it?</summary>

Since variable values are dynamic, there's no point in replacing them with a single alias. Synthesized message would always be the same regardless of the variable's value.

</details>

<details>

<summary>Why is it challenging to customize the synthesis intonation of text with variables?</summary>

Variable values might significantly vary in length and therefore the rhythm of speech, the number of syllables, vowel content and a prosody of a sentence is a slightly different with every case.

```

SPEECH input: Jste prosím {gender} {name_surname}?

Possible text-to-speech outputs:
Jste prosím pan Jan Kár?
Jste prosím pan Ivo Krč?
Jste prosím pan Pavel Novák?
Jste prosím paní Eva Černá?
Jste prosím paní Eliška Drahokoupilová?
Jste prosím paní Filomena Strčskrzprstová?
Jste prosím pan Květoslav Podhorodecký?
[...]
```

Only way to handle this situation is to temporarily substitute variables with some dummy values as examples.

:bulb: **Try various intonation curves until finding one configuration that is acceptable on all dummy cases.**

</details>
