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

# Step 5: Text to Speech (TTS)

> Follow the instructions below to set up and use Text to Speech (TTS) capabilities. 

## General Setup

1. Create `TTSConfig` Prefab and Assign it to you Character’s `TTSManager` component (there is one provided inside `GladeCore Scripts -> TTS -> Config`)

<img src="https://mintcdn.com/gladestudio/N3nLeCrM6d7QXisw/images/unity/Unity_TTSConfigPrefabCreate.png?fit=max&auto=format&n=N3nLeCrM6d7QXisw&q=85&s=3ba8af2236029cfcd3874e5b02f3bce9" alt="Unity TTS Config Prefab Create" width="842" height="909" data-path="images/unity/Unity_TTSConfigPrefabCreate.png" />

2. Open `NPCPersonalityData` Prefab used for the your character

<img src="https://mintcdn.com/gladestudio/N3nLeCrM6d7QXisw/images/unity/Unity_TTSNPCPersonalityDataPrefabSettingsTTSProvider.png?fit=max&auto=format&n=N3nLeCrM6d7QXisw&q=85&s=a0e03c551b70d23a38e8e89eaecd2fac" alt="Unity TTSNPC Personality Data Prefab Settings TTS Provider" width="1022" height="322" data-path="images/unity/Unity_TTSNPCPersonalityDataPrefabSettingsTTSProvider.png" />

3. Select TTS Provider (None means disable TTS). We recommend ElevenLabs as local options for TTS are still very slow and lower quality.

* ElevenLabs

<img src="https://mintcdn.com/gladestudio/N3nLeCrM6d7QXisw/images/unity/Unity_TTSElevenLabsVoiceConfig.png?fit=max&auto=format&n=N3nLeCrM6d7QXisw&q=85&s=e67a3a4733ca92e53e3286c140606452" alt="Unity TTS Eleven Labs Voice Config" width="985" height="251" data-path="images/unity/Unity_TTSElevenLabsVoiceConfig.png" />

* Spark TTS (Slow Generation Speed, use it for research)

<img src="https://mintcdn.com/gladestudio/N3nLeCrM6d7QXisw/images/unity/Unity_TTSSparkttsVoiceConfig.png?fit=max&auto=format&n=N3nLeCrM6d7QXisw&q=85&s=50959298007931bfa88b74909d08f17e" alt="Unity TTS Sparktts Voice Config" width="983" height="255" data-path="images/unity/Unity_TTSSparkttsVoiceConfig.png" />

4. Check Enable TTS in NPCChatComponent of your character

<img src="https://mintcdn.com/gladestudio/N3nLeCrM6d7QXisw/images/unity/Unity_TTSEnableTTSCheck.png?fit=max&auto=format&n=N3nLeCrM6d7QXisw&q=85&s=98094b075824ef7162b6a379e5698aa3" alt="Unity TTS Enable TTS Check" width="993" height="76" data-path="images/unity/Unity_TTSEnableTTSCheck.png" />

## TTS Config

Follow the configuration steps below, first section is ElevenLabs config and section section is for Spark TTS.

1. **Cloud TTS Provider Configuration (ElevenLabs)**
   * Open TTS Config

<img src="https://mintcdn.com/gladestudio/sZ9hsSZ4qG82jkCx/images/unity/Unity_TTSConfigElevenLabs.png?fit=max&auto=format&n=sZ9hsSZ4qG82jkCx&q=85&s=49c80293168c5631a2e513537c534a1b" alt="Unity TTS Config Eleven Labs" width="436" height="663" data-path="images/unity/Unity_TTSConfigElevenLabs.png" />

* Add your ElevenLabs API Key and Press Save API Key

<img src="https://mintcdn.com/gladestudio/sZ9hsSZ4qG82jkCx/images/unity/Unity_TTSConfigElevenLabsSaveAPIKey.png?fit=max&auto=format&n=sZ9hsSZ4qG82jkCx&q=85&s=eadb810e7e934a0862a4d438fd44ac27" alt="Unity TTS Config Eleven Labs Save API Key" width="645" height="551" data-path="images/unity/Unity_TTSConfigElevenLabsSaveAPIKey.png" />

* Click `Test API Connection` to test

<img src="https://mintcdn.com/gladestudio/sZ9hsSZ4qG82jkCx/images/unity/Unity_TTSConfigElevenLabsTestAPIConnection.png?fit=max&auto=format&n=sZ9hsSZ4qG82jkCx&q=85&s=8d81da37af16a0dcaf140da40dbed019" alt="Unity TTS Config Eleven Labs Test API Connection" width="540" height="367" data-path="images/unity/Unity_TTSConfigElevenLabsTestAPIConnection.png" />

2. [**Spark TTS Setup**](https://github.com/arghyasur1991/Spark-TTS-Unity)

Using Unity Package Manager (Recommended):

1. Open your Unity project
2. Open the Package Manager (Window > Package Manager)
3. Click the "+" button in the top-left corner
4. Select "Add package from git URL..."
5. Enter the repository URL: [https://github.com/arghyasur1991/Spark-TTS-Unity.git](https://github.com/arghyasur1991/Spark-TTS-Unity.git)
6. Click "Add"

Download pre-exported ONNX models here \
[<u>https://drive.google.com/file/d/1YXj81ApcEasY17a8Zj9RqTpvn4s1UKk7/view</u>](https://drive.google.com/file/d/1YXj81ApcEasY17a8Zj9RqTpvn4s1UKk7/view)

1. Download/Unzip files from link
2. Move the SparkTTS folder directly into the Assets/models folder. If there is none, make one.
3. Use the Model Deployment Tool found at the top of Unity Editor 

<img src="https://mintcdn.com/gladestudio/4ywPtyMiYvy6TEeW/images/unity/Unity_SparkTTSModelDeployment.png?fit=max&auto=format&n=4ywPtyMiYvy6TEeW&q=85&s=3198feee95d4eb7bf9e75eeb0b112a91" alt="Unity Spark TTS Model Deployment" title="Unity Spark TTS Model Deployment" className="mx-auto" style={{ width:"70%" }} width="446" height="130" data-path="images/unity/Unity_SparkTTSModelDeployment.png" />

<img src="https://mintcdn.com/gladestudio/4ywPtyMiYvy6TEeW/images/unity/Unity_SparkTTSModelDeploymentConfig.png?fit=max&auto=format&n=4ywPtyMiYvy6TEeW&q=85&s=5bc55d2d8f8b0b7d1e6ae9aaab107d72" alt="Unity Spark TTS Model Deployment Config" width="583" height="539" data-path="images/unity/Unity_SparkTTSModelDeploymentConfig.png" />

Click Deploy SparkTTS Models once you see all the selected models from the folder in Assets/models.
