Use text-to-speech for incoming messages
How to synthesize incoming text messages as speech.
読み終わるまでの所要時間 1 分最終更新 7ヶ月前
To use text-to-speech (TTS) to read incoming messages, use the function in the message event handler. We recommend that you use the destination because it ensures that messages are queued and that they only play locally.
Speak()TTSDestination::QueuedLocalPlayback- When a text message is received in a channel, the event is raised.
IChannelSession::EventTextMessageReceived - When a direct message is received in a channel, the event is raised.
ILoginSession::EventDirectedTextMessageReceived
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); }});