# Use text-to-speech for incoming messages

> How to synthesize incoming text messages as speech.

To use text-to-speech (TTS) to read incoming messages, use the `Speak()` function in the message event handler. We recommend that you use the `TTSDestination::QueuedLocalPlayback` destination because it ensures that messages are queued and that they only play locally.

* [When a text message is received in a channel](../messaging/group-text-messages), the `IChannelSession::EventTextMessageReceived` event is raised.
* [When a direct message is received in a channel](../messaging/directed-text-voice), the `ILoginSession::EventDirectedTextMessageReceived` event is raised.

The following code is an example of how to use TTS for channel messages:

```plaintext
MyChannelSession->EventTextMessageReceived.AddLambda([MyLoginSession](const IChannelTextMessage &Message)
{
    // If the text message received is not from me...
    if (Message.Sender() != MyLoginSession->LoginSessionId())
    {
        // Check if optional display name is set.
        FString DisplayName = Message.Sender().DisplayName();
        if (DisplayName.IsEmpty())
            { DisplayName = "Anonymous"; }

        // This queues the message and lets the user know who sent it.
        // NB: the colon (:) inserts a slight pause before subsequent text.
        FString Text = DisplayName + " says: " + Message.Message();
        MyLoginSession->TTS().Speak(Text, TTSDestination::QueuedLocalPlayback);
    }
});
```

> **Note:**
>
> To only read text messages from other users in a channel, compare the current user’s AccountId with the IChannelTextMessage::Sender() value.
