API reference
API reference
Select your platform
No SDKs available
No versions available

TTSService Class

Extends MonoBehaviour

Properties

static TTSService Instance[Get]
Audio system to be used for streaming & playback
abstract ITTSRuntimeCacheHandler RuntimeCacheHandler[Get]
abstract ITTSDiskCacheHandler DiskCacheHandler[Get]
abstract ITTSWebHandler WebHandler[Get]
abstract ITTSVoiceProvider VoiceProvider[Get]

Events

Static event called whenever any TTSService.Awake is called
Static event called whenever any TTSService.OnDestroy is called

Fields

TTSServiceEvents Events[Get]

Member Functions

Returns error if invalid
Gets the text to be spoken after applying all relevant voice settings.
Parameters
textToSpeak
Text to be spoken by a particular voice
voiceSettings
Voice settings to be used
Returns
Returns a the final text to be spoken
Obtain unique id for clip data
TTSClipData Load
( string textToSpeak,
Action< TTSClipData, string > onStreamReady )
TTSClipData Load
( string textToSpeak,
string presetVoiceId,
Action< TTSClipData, string > onStreamReady )
TTSClipData Load
( string textToSpeak,
string presetVoiceId,
TTSDiskCacheSettings diskCacheSettings,
Action< TTSClipData, string > onStreamReady )
TTSClipData Load
( string textToSpeak,
TTSVoiceSettings voiceSettings,
TTSDiskCacheSettings diskCacheSettings,
Action< TTSClipData, string > onStreamReady )
Perform a request for a audio clip
Parameters
textToSpeak
Text to be spoken in clip
clipID
Unique clip id
voiceSettings
Custom voice settings
diskCacheSettings
Custom cache settings
Returns
Generated clip data
Unload all audio clips from the runtime cache
Force a runtime cache unload
Obtain a clip from the runtime cache, if applicable
Obtain all clips from the runtime cache, if applicable
Whether a specific clip should be cached
Parameters
clipData
Clip data
Returns
True if should be cached
Get disk cache
Parameters
textToSpeak
Text to be spoken in clip
clipID
Unique clip id
voiceSettings
Custom voice settings
diskCacheSettings
Custom disk cache settings
Returns
TTSClipData DownloadToDiskCache
( string textToSpeak,
Action< TTSClipData, string, string > onDownloadComplete )
TTSClipData DownloadToDiskCache
( string textToSpeak,
string presetVoiceId,
Action< TTSClipData, string, string > onDownloadComplete )
TTSClipData DownloadToDiskCache
( string textToSpeak,
string presetVoiceId,
TTSDiskCacheSettings diskCacheSettings,
Action< TTSClipData, string, string > onDownloadComplete )
TTSClipData DownloadToDiskCache
( string textToSpeak,
TTSVoiceSettings voiceSettings,
TTSDiskCacheSettings diskCacheSettings,
Action< TTSClipData, string, string > onDownloadComplete )
Perform a download for a audio clip
Parameters
textToSpeak
Text to be spoken in clip
clipID
Unique clip id
voiceSettings
Custom voice settings
diskCacheSettings
Custom disk cache settings
onDownloadComplete
Callback when file has finished downloading
Returns
Generated clip data
Return all preset voice settings
Returns
Return preset voice settings for a specific id
Parameters
presetVoiceId
Returns

Protected Functions

virtual void Awake ( )
virtual void Start ( )
virtual void OnEnable ( )
virtual void OnDisable ( )
virtual void AddDelegates ( )
virtual void RemoveDelegates ( )
virtual void OnDestroy ( )
virtual void AppendFinalText
( StringBuilder builder,
string textToSpeak,
TTSVoiceSettings voiceSettings )
Creates new clip data or returns existing cached clip
Parameters
textToSpeak
Text to speak
clipID
Unique clip id
voiceSettings
Voice settings
diskCacheSettings
Disk Cache settings
Returns
Clip data structure
virtual IAudioClipStream CreateClipStream ( )
virtual AudioType GetAudioType ( )
virtual bool GetShouldAudioStream
( AudioType audioType )
virtual bool ShouldUseEvents
( AudioType audioType )
virtual void SetClipLoadState
( TTSClipData clipData,
TTSClipLoadState loadState )
virtual void RaiseRequestProgressUpdated
( TTSClipData clipData,
float newProgress )
Perform clip unload
Parameters
clipID
Called when runtime cache adds a clip
Parameters
clipData
Called when runtime cache unloads a clip
Parameters
clipData
Clip to be unloaded
virtual void DownloadToDiskCache
( TTSClipData clipDataParam,
Action< TTSClipData, string, string > onDownloadComplete )
Did you find this page helpful?
Thumbs up icon
Thumbs down icon