Documentation

Support

Vivox Unreal SDK

Vivox Unreal SDK

Use text-to-speech for incoming messages

How to synthesize incoming text messages as speech.
Read time 1 minuteLast updated 2 days ago

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.
The following code is an example of how to use TTS for channel messages:
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); }});