Documentation

Support

Vivox Unreal SDK

Vivox Unreal SDK

ITextToSpeech

Reference the ITextToSpeech interface for text-to-speech functionality.
Read time 4 minutesLast updated 2 days ago

An interface for events and methods related to text-to-speech (TTS).
#include <ITextToSpeech.h>

Public Functions

Name

DECLARE_EVENT_ThreeParams(ITextToSpeech , PlaybackStarted , unsigned int , const ITTSMessage & , double )
DECLARE_EVENT_TwoParams(ITextToSpeech , PlaybackCompleted , unsigned int , const ITTSMessage & )
DECLARE_EVENT_TwoParams(ITextToSpeech , PlaybackFailed , VivoxCoreError , const ITTSMessage & )
virtual const TMap< FString, ITTSVoice * > &GetAvailableVoices() =0
All voices available to the text-to-speech subsystem for speech synthesis, indexed by name.
virtual const ITTSVoice &GetCurrentVoice() =0
The voice used by text-to-speech methods called from this ILoginSession.
virtual boolSetCurrentVoice(const ITTSVoice & newVoice) =0
Set the voice used by text-to-speech methods called from this ILoginSession.
virtual VivoxCoreErrorSpeak(const FString & text, const TTSDestination & destination, ITTSMessage ** outMessage =nullptr) =0
Inject a new text-to-speech (TTS) message into the specified destination.
virtual VivoxCoreErrorSpeakToBuffer(const FString & text, ITTSAudioBuffer ** outBuffer) =0
Inject a new text-to-speech message into an audio buffer for direct use.
virtual VivoxCoreErrorCancelMessage(const ITTSMessage & message) =0
Cancel a single currently playing or enqueued text-to-speech message.
virtual VivoxCoreErrorCancelDestination(const TTSDestination & destination) =0
Cancel all text-to-speech messages in a destination (ongoing and enqueued).
virtual VivoxCoreErrorCancelAll() =0
Cancel all text-to-speech messages (ongoing and enqueued) from all destinations.
virtual const TArray< ITTSMessage * > &GetMessages(const TTSDestination & destination) =0
Retrieve ongoing or enqueued text-to-speech (TTS) messages that were previously created by using Speak().

Public Attributes

Name

PlaybackStartedEventPlaybackStarted
An event that indicates a text-to-speech (TTS) message has finished preparing for playback and is starting to play.
PlaybackCompletedEventPlaybackCompleted
An event that indicates a text-to-speech (TTS) message has finished playback.
PlaybackFailedEventPlaybackFailed
An event that indicates playback of a text-to-speech message has failed.

Public Functions Documentation

function DECLARE_EVENT_ThreeParams

DECLARE_EVENT_ThreeParams( ITextToSpeech , PlaybackStarted , unsigned int , const ITTSMessage & , double )

function DECLARE_EVENT_TwoParams

DECLARE_EVENT_TwoParams( ITextToSpeech , PlaybackCompleted , unsigned int , const ITTSMessage & )

function DECLARE_EVENT_TwoParams

DECLARE_EVENT_TwoParams( ITextToSpeech , PlaybackFailed , VivoxCoreError , const ITTSMessage & )

function GetAvailableVoices

virtual const TMap< FString, ITTSVoice * > & GetAvailableVoices() =0
All voices available to the text-to-speech subsystem for speech synthesis, indexed by name.

function GetCurrentVoice

virtual const ITTSVoice & GetCurrentVoice() =0
The voice used by text-to-speech methods called from this ILoginSession. Return: The voice previously set with SetCurrentVoice(), or the SDK default voice if never set.

function SetCurrentVoice

virtual bool SetCurrentVoice( const ITTSVoice & newVoice) =0
Set the voice used by text-to-speech methods called from this ILoginSession. Parameters: Return: True if a new value is set, false if a voice is not available (for example, if a voice is loaded from saved settings).

function Speak

virtual VivoxCoreError Speak( const FString & text, const TTSDestination & destination, ITTSMessage ** outMessage =nullptr) =0
Inject a new text-to-speech (TTS) message into the specified destination. Parameters:
  • text The text to be converted into speech.
  • destination Determines the output stream and mechanism for TTS injection.
  • outMessage [out, optional] An object that holds properties related to this TTS message.
Remark: For information on how the ITTSVoice used for speech synthesis is selected, see GetCurrentVoice().

function SpeakToBuffer

virtual VivoxCoreError SpeakToBuffer( const FString & text, ITTSAudioBuffer ** outBuffer) =0
Inject a new text-to-speech message into an audio buffer for direct use. Parameters:
  • text The text to be converted into speech.
  • outBuffer [out] An object that contains raw audio data and metadata, such as buffer length and audio format properties.
Remark: For information on how the ITTSVoice used for speech synthesis is selected, see GetCurrentVoice().

function CancelMessage

virtual VivoxCoreError CancelMessage( const ITTSMessage & message) =0
Cancel a single currently playing or enqueued text-to-speech message. Parameters: Remark: In destinations with queues, canceling an ongoing message automatically triggers the playback of the next message. Canceling an enqueued message shifts all later messages up one place in the queue.

function CancelDestination

virtual VivoxCoreError CancelDestination( const TTSDestination & destination) =0
Cancel all text-to-speech messages in a destination (ongoing and enqueued). Parameters:
  • destination The TTSDestination to clear of messages.
Remark: The TTSDestinations QueuedRemoteTransmission and QueuedRemoteTransmissionWithLocalPlayback share a queue, but are not the same destination. Canceling all messages in one of these destinations automatically triggers the playback of the next message from the other destination in the shared queue.

function CancelAll

virtual VivoxCoreError CancelAll() =0
Cancel all text-to-speech messages (ongoing and enqueued) from all destinations.

function GetMessages

virtual const TArray< ITTSMessage * > & GetMessages( const TTSDestination & destination) =0
Retrieve ongoing or enqueued text-to-speech (TTS) messages that were previously created by using Speak(). Parameters:
  • destination The TTSDestination to retrieve messages for.
Return: An array of all TTS messages that are playing or enqueued in the specified destination.

Public Attributes Documentation

variable EventPlaybackStarted

PlaybackStarted EventPlaybackStarted;
An event that indicates a text-to-speech (TTS) message has finished preparing for playback and is starting to play. Parameters:
  • numConsumers The number of active sessions (for remote playback destinations), local players (for local playback destinations), or both, that the TTS message is playing into.
  • message The ITTSMessage that corresponds to this speech.
  • messageDuration The duration of the synthesized voice clip in seconds.

variable EventPlaybackCompleted

PlaybackCompleted EventPlaybackCompleted;
An event that indicates a text-to-speech (TTS) message has finished playback. Parameters:
  • numConsumers The number of active sessions (for remote playback destinations), local players (for local playback destinations), or both, that the TTS message is playing into.
  • message The ITTSMessage that corresponds to this speech.
Remark: This event is raised regardless of whether playback is stopped early by using the various Cancel*() methods, is replaced by a new message (TTSDestination.ScreenReader only), or if the voice clip has reached its natural end. When this event is received, the correponding ITTSMessage can no longer be obtained by using GetMessages().

variable EventPlaybackFailed

PlaybackFailed EventPlaybackFailed;
An event that indicates playback of a text-to-speech message has failed. Parameters:
  • status The error code of the failure.
  • message The ITTSMessage that corresponds to this speech.
Remark: When this event is received, the correponding ITTSMessage can no longer be obtained by using GetMessages().