# Text To Speech  ( TTS )

## Inherit from EasyManager.cs

```csharp
using EasyCodeForVivox;

public class VivoxManager : EasyManager
{

}
```

## Inject EasyTextToSpeech

```csharp
using EasyCodeForVivox;
using UnityEngine;
using Zenject;

public class VivoxTextToSpeech : MonoBehaviour
{
    EasyTextToSpeech _textToSpeech;

    [Inject]
    private void Initialize(EasyTextToSpeech textToSpeech)
    {
        _textToSpeech = textToSpeech;
    }
}
```

{% hint style="info" %}
For more information on the available **Text-To-Speech options** check out the [**Vivox Documentation**](https://docs.vivox.com/v5/general/unity/15_1_190000/en-us/Default.htm#Unity/developer-guide/text-to-speech/tts-destinations.htm%3FTocPath%3DVivox%2520Unity%2520SDK%2520documentation%7CVivox%2520Unity%2520Developer%2520Guide%7CText-to-speech%7C_____2)
{% endhint %}

### **Choosing Voice Gender**

This method allows you to choose male or female voice. **Vivox only supports English Voices**

{% hint style="warning" %}
If you're a Christian, the male voice doesn’t pronounce Jesus’s name correctly so I recommend using the female voice or you can provide your players with the option to choose
{% endhint %}

#### EasyManager

```csharp
public void ChooseVivoxVoice()
{
    ChooseVoiceGender(VoiceGender.female, "userName");
}
```

#### EasyTextToSpeech

```csharp
public void ChooseVivoxVoice()
{
    _textToSpeech.ChooseVoiceGender(VoiceGender.female, "userName");
}
```

## Local Text-to-Speech (TTS)

### Local

Speak TTS Messages Locally. Messages will play over each other

**Parameters Include:**

* **`string`** message = Message to Speak
* **`string`** userName = Username of player
* **`TTSDestination`** = Refer to [Vivox Documentation](https://docs.vivox.com/v5/general/unity/15_1_190000/en-us/Default.htm#Unity/developer-guide/text-to-speech/tts-destinations.htm%3FTocPath%3DVivox%2520Unity%2520SDK%2520documentation%7CVivox%2520Unity%2520Developer%2520Guide%7CText-to-speech%7C_____2)

#### EasyManager

```csharp
public void TTSMsgLocalPlayOverCurrent()
{
    PlayTTSMessage("my message to play", "userName", TTSDestination.LocalPlayback);
}
```

#### EasyTextToSpeech

```csharp
public void TTSMsgLocalPlayOverCurrent()
{
    _textToSpeech.PlayTTSMessage("my message to play", TTSDestination.LocalPlayback, EasySession.LoginSessions["userName"]);
}
```

### Local Queued

Speak TTS Messages Locally. Messages will be added to a queue and played in order recieved

**Parameters Include:**

* **`string`** message = Message to Speak
* **`string`** userName = Username of player
* **`TTSDestination`** = Refer to [Vivox Documentation](https://docs.vivox.com/v5/general/unity/15_1_190000/en-us/Default.htm#Unity/developer-guide/text-to-speech/tts-destinations.htm%3FTocPath%3DVivox%2520Unity%2520SDK%2520documentation%7CVivox%2520Unity%2520Developer%2520Guide%7CText-to-speech%7C_____2)

#### EasyManager

```csharp
public void TTSMsgQueueLocal()
{
    _textToSpeech.PlayTTSMessage("my message to play", TTSDestination.QueuedLocalPlayback, EasySession.LoginSessions["userName"]);
}
```

#### EasyTextToSpeech

```csharp
public void TTSMsgQueueRemoteLocal()
{
    PlayTTSMessage("my message to play",  "userName", TTSDestination.QueuedRemoteTransmissionWithLocalPlayback);
}
```

### Local Screen Reader

Speak TTS Messages Locally. Messages will replace each other

**Parameters Include:**

* **`string`** message = Message to Speak
* **`string`** userName = Username of player
* **`TTSDestination`** = Refer to [Vivox Documentation](https://docs.vivox.com/v5/general/unity/15_1_190000/en-us/Default.htm#Unity/developer-guide/text-to-speech/tts-destinations.htm%3FTocPath%3DVivox%2520Unity%2520SDK%2520documentation%7CVivox%2520Unity%2520Developer%2520Guide%7CText-to-speech%7C_____2)

#### EasyManager

```csharp
public void TTSMsgLocalReplaceCurrentMessagePlaying()
{
    PlayTTSMessage("my message to play",  "userName", TTSDestination.ScreenReader);
}
```

#### EasyTextToSpeech

```csharp
public void TTSMsgLocalReplaceCurrentMessagePlaying()
{
    _textToSpeech.PlayTTSMessage("my message to play", TTSDestination.ScreenReader, EasySession.LoginSessions["userName"]);
}
```

## Remote Text-to-Speech (TTS)

### Remote

Speak TTS Messages Remotely. Messages will play over each other

**Parameters Include:**

* **`string`** message = Message to Speak
* **`string`** userName = Username of player
* **`TTSDestination`** = Refer to [Vivox Documentation](https://docs.vivox.com/v5/general/unity/15_1_190000/en-us/Default.htm#Unity/developer-guide/text-to-speech/tts-destinations.htm%3FTocPath%3DVivox%2520Unity%2520SDK%2520documentation%7CVivox%2520Unity%2520Developer%2520Guide%7CText-to-speech%7C_____2)

#### EasyManager

```csharp
public void TTSMsgRemotePlayOverCurrent()
{
    PlayTTSMessage("my message to play",  "userName", TTSDestination.RemoteTransmission);
}
```

#### EasyTextToSpeech

```csharp
public void TTSMsgRemotePlayOverCurrent()
{
    _textToSpeech.PlayTTSMessage("my message to play", TTSDestination.RemoteTransmission, EasySession.LoginSessions["userName"]);
}
```

### Remote Queued

Speak TTS Messages Remotely. Messages will be added to a queue and played in order received

**Parameters Include:**

* **`string`** message = Message to Speak
* **`string`** userName = Username of player
* **`TTSDestination`** = Refer to [Vivox Documentation](https://docs.vivox.com/v5/general/unity/15_1_190000/en-us/Default.htm#Unity/developer-guide/text-to-speech/tts-destinations.htm%3FTocPath%3DVivox%2520Unity%2520SDK%2520documentation%7CVivox%2520Unity%2520Developer%2520Guide%7CText-to-speech%7C_____2)

#### EasyManager

```csharp
public void TTSMsgQueueRemote()
{
    PlayTTSMessage("my message to play",  "userName", TTSDestination.QueuedRemoteTransmission);
}
```

#### EasyTextToSpeech

```csharp
public void TTSMsgQueueRemote()
{
    _textToSpeech.PlayTTSMessage("my message to play", TTSDestination.QueuedRemoteTransmission, EasySession.LoginSessions["userName"]);
}
```

## Remote and Local Text-to-Speech (TTS)

### Remote and Local

Speak TTS Messages Remotely and Locally. Messages will play over each other

**Parameters Include:**

* **`string`** message = Message to Speak
* **`string`** userName = Username of player
* **`TTSDestination`** = Refer to [Vivox Documentation](https://docs.vivox.com/v5/general/unity/15_1_190000/en-us/Default.htm#Unity/developer-guide/text-to-speech/tts-destinations.htm%3FTocPath%3DVivox%2520Unity%2520SDK%2520documentation%7CVivox%2520Unity%2520Developer%2520Guide%7CText-to-speech%7C_____2)

#### EasyManager

```csharp
public void TTSMsgLocalRemotePlayOverCurrent()
{
    PlayTTSMessage("my message to play",  "userName", TTSDestination.RemoteTransmissionWithLocalPlayback);
}
```

#### EasyTextToSpeech

```csharp
public void TTSMsgLocalRemotePlayOverCurrent()
{
    _textToSpeech.PlayTTSMessage("my message to play", TTSDestination.RemoteTransmissionWithLocalPlayback, EasySession.LoginSessions["userName"]);
}
```

### Remote and Local Queued

Speak TTS Messages Remotely and Locally. Messages will be added to a queue and played in order received

**Parameters Include:**

* **`string`** message = Message to Speak
* **`string`** userName = Username of player
* **`TTSDestination`** = Refer to [Vivox Documentation](https://docs.vivox.com/v5/general/unity/15_1_190000/en-us/Default.htm#Unity/developer-guide/text-to-speech/tts-destinations.htm%3FTocPath%3DVivox%2520Unity%2520SDK%2520documentation%7CVivox%2520Unity%2520Developer%2520Guide%7CText-to-speech%7C_____2)

#### EasyManager

```csharp
public void TTSMsgQueueRemoteLocal()
{
    PlayTTSMessage("my message to play",  "userName", TTSDestination.QueuedRemoteTransmissionWithLocalPlayback);
}
```

#### EasyTextToSpeech

```csharp
public void TTSMsgQueueRemoteLocal()
{
    _textToSpeech.PlayTTSMessage("my message to play", TTSDestination.QueuedRemoteTransmissionWithLocalPlayback, EasySession.LoginSessions["userName"]);
}
```
