API reference

TTSService Class

Extends MonoBehaviour
Abstract script for loading and returning text-to-speech clip streams.

Fields

Signature
TTSServiceEvents Meta.WitAi.TTS.TTSService.Events

Properties

AudioSystem : IAudioSystem
[Get][Set]
Audio system to be used for obtaining audio clip streams
Signature
IAudioSystem Meta.WitAi.TTS.TTSService.AudioSystem
DiskCacheHandler : ITTSDiskCacheHandler
[Get][Set]
Disk cache that assists with the backup and retrieval of audio clips saved to disk.
Signature
ITTSDiskCacheHandler Meta.WitAi.TTS.TTSService.DiskCacheHandler
Instance : TTSService
[Get]
Static singleton to be used when interacting with a single TTSService
Signature
TTSService Meta.WitAi.TTS.TTSService.Instance
Logger : IVLogger
[Get]
Signature
IVLogger Meta.WitAi.TTS.TTSService.Logger
RuntimeCacheHandler : ITTSRuntimeCacheHandler
[Get][Set]
Runtime cache that assists with the temporary storage of audio clips
Signature
ITTSRuntimeCacheHandler Meta.WitAi.TTS.TTSService.RuntimeCacheHandler
VoiceProvider : abstract ITTSVoiceProvider
[Get]
Signature
abstract ITTSVoiceProvider Meta.WitAi.TTS.TTSService.VoiceProvider
WebHandler : abstract ITTSWebHandler
[Get]
Signature
abstract ITTSWebHandler Meta.WitAi.TTS.TTSService.WebHandler

Events

OnServiceDestroy : Action< TTSService >
Static event called whenever any TTSService.OnDestroy is called
Signature
Action<TTSService> Meta.WitAi.TTS.TTSService.OnServiceDestroy
OnServiceStart : Action< TTSService >
Static event called whenever any TTSService.Awake is called
Signature
Action<TTSService> Meta.WitAi.TTS.TTSService.OnServiceStart

Protected Methods

Awake ()
Signature
virtual void Meta.WitAi.TTS.TTSService.Awake()
Returns
void
GetClipIDWithFinalText ( formattedText , voiceSettings )
Obtain unique id for clip data with text that has already been passed through GetFinalText
Signature
virtual string Meta.WitAi.TTS.TTSService.GetClipIDWithFinalText(string formattedText, TTSVoiceSettings voiceSettings)
Parameters
formattedText: string
voiceSettings: TTSVoiceSettings
Returns
string
GetInterface< TInterface > ( current )
Obtains a script implementing a specific interface on this game object
Signature
TInterface Meta.WitAi.TTS.TTSService.GetInterface< TInterface >(TInterface current)
Parameters
current: TInterface
Returns
TInterface
GetOrCreateInterface< TInterface, TDefault > ( current )
Obtains a script implementing an interface or generates one if not found.
Signature
TInterface Meta.WitAi.TTS.TTSService.GetOrCreateInterface< TInterface, TDefault >(TInterface current)
Parameters
current: TInterface
Returns
TInterface
OnDestroy ()
Signature
virtual void Meta.WitAi.TTS.TTSService.OnDestroy()
Returns
void
OnDisable ()
Signature
virtual void Meta.WitAi.TTS.TTSService.OnDisable()
Returns
void
OnEnable ()
Signature
virtual void Meta.WitAi.TTS.TTSService.OnEnable()
Returns
void
OnRuntimeClipAdded ( clipData )
Called when runtime cache adds a clip
Signature
virtual void Meta.WitAi.TTS.TTSService.OnRuntimeClipAdded(TTSClipData clipData)
Parameters
clipData: TTSClipData
Returns
void
OnRuntimeClipRemoved ( clipData )
Called when runtime cache unloads a clip
Signature
virtual void Meta.WitAi.TTS.TTSService.OnRuntimeClipRemoved(TTSClipData clipData)
Parameters
clipData: TTSClipData  Clip to be unloaded
Returns
void
SetClipLoadState ( clipData , loadState )
Signature
virtual void Meta.WitAi.TTS.TTSService.SetClipLoadState(TTSClipData clipData, TTSClipLoadState loadState)
Parameters
clipData: TTSClipData
loadState: TTSClipLoadState
Returns
void
SetListeners ( add )
Sets listeners to add or remove
Signature
virtual void Meta.WitAi.TTS.TTSService.SetListeners(bool add)
Parameters
add: bool
Returns
void
Start ()
Signature
virtual void Meta.WitAi.TTS.TTSService.Start()
Returns
void

Methods

DecodeTts ( responseNode , textToSpeak , voiceSettings )
Decode a response node into text to be spoken or a specific voice setting
Signature
bool Meta.WitAi.TTS.TTSService.DecodeTts(WitResponseNode responseNode, out string textToSpeak, out TTSVoiceSettings voiceSettings)
Parameters
responseNode: WitResponseNode  Parsed data that includes text to be spoken and voice settings
textToSpeak: out string  The text to be spoken output
voiceSettings: out TTSVoiceSettings  The output for voice settings
Returns
bool  True if decode was successful
DownloadAsync ( textToSpeak , voiceSettings , diskCacheSettings )
Perform a download for a TTS audio clip
Signature
async Task<string> Meta.WitAi.TTS.TTSService.DownloadAsync(string textToSpeak, TTSVoiceSettings voiceSettings, TTSDiskCacheSettings diskCacheSettings)
Parameters
textToSpeak: string  Text to be spoken in clip
voiceSettings: TTSVoiceSettings  Custom voice settings
diskCacheSettings: TTSDiskCacheSettings  Custom disk cache settings
Returns
async Task< string >  Any errors that occured during the download process
DownloadToDiskCache ( textToSpeak , presetVoiceId , diskCacheSettings , onDownloadComplete )
Perform a download for a TTS audio clip
Signature
TTSClipData Meta.WitAi.TTS.TTSService.DownloadToDiskCache(string textToSpeak, string presetVoiceId, TTSDiskCacheSettings diskCacheSettings=null, Action< TTSClipData, string, string > onDownloadComplete=null)
Parameters
textToSpeak: string  Text to be spoken in clip
presetVoiceId: string  Specific voice id
diskCacheSettings: TTSDiskCacheSettings  Custom disk cache settings
onDownloadComplete: Action< TTSClipData, string, string >  Callback when file has finished downloading
Returns
TTSClipData  Generated TTS clip data
DownloadToDiskCache ( textToSpeak , voiceSettings , diskCacheSettings , onDownloadComplete )
Perform a download for a TTS audio clip
Signature
TTSClipData Meta.WitAi.TTS.TTSService.DownloadToDiskCache(string textToSpeak, TTSVoiceSettings voiceSettings, TTSDiskCacheSettings diskCacheSettings=null, Action< TTSClipData, string, string > onDownloadComplete=null)
Parameters
textToSpeak: string  Text to be spoken in clip
voiceSettings: TTSVoiceSettings  Custom voice settings
diskCacheSettings: TTSDiskCacheSettings  Custom disk cache settings
onDownloadComplete: Action< TTSClipData, string, string >  Callback when file has finished downloading with success or error
Returns
TTSClipData  Generated TTS clip data
GetAllPresetVoiceSettings ()
Return all preset voice settings
Signature
TTSVoiceSettings [] Meta.WitAi.TTS.TTSService.GetAllPresetVoiceSettings()
Returns
TTSVoiceSettings []
GetAllRuntimeCachedClips ()
Obtain all clips from the runtime cache, if applicable
Signature
TTSClipData [] Meta.WitAi.TTS.TTSService.GetAllRuntimeCachedClips()
Returns
TTSClipData []
GetClipData ( textToSpeak , voiceSettings , diskCacheSettings )
Creates new clip data or returns existing cached clip
Signature
TTSClipData Meta.WitAi.TTS.TTSService.GetClipData(string textToSpeak, TTSVoiceSettings voiceSettings, TTSDiskCacheSettings diskCacheSettings)
Parameters
textToSpeak: string  Text to speak
voiceSettings: TTSVoiceSettings Voice settings
diskCacheSettings: TTSDiskCacheSettings  Disk Cache settings
Returns
TTSClipData  Clip data structure
GetClipID ( textToSpeak , voiceSettings )
Obtain unique id for clip data using provided text
Signature
string Meta.WitAi.TTS.TTSService.GetClipID(string textToSpeak, TTSVoiceSettings voiceSettings)
Parameters
textToSpeak: string
voiceSettings: TTSVoiceSettings
Returns
string
GetDiskCachePath ( textToSpeak , clipID , voiceSettings , diskCacheSettings )
Get disk cache
Signature
string Meta.WitAi.TTS.TTSService.GetDiskCachePath(string textToSpeak, string clipID, TTSVoiceSettings voiceSettings, TTSDiskCacheSettings diskCacheSettings)
Parameters
textToSpeak: string  Text to be spoken in clip
clipID: string  Unique clip id
voiceSettings: TTSVoiceSettings  Custom voice settings
diskCacheSettings: TTSDiskCacheSettings  Custom disk cache settings
Returns
string
GetFinalText ( textToSpeak , voiceSettings )
Gets the text to be spoken after applying all relevant voice settings.
Signature
virtual string Meta.WitAi.TTS.TTSService.GetFinalText(string textToSpeak, TTSVoiceSettings voiceSettings)
Parameters
textToSpeak: string  Text to be spoken by a particular voice
voiceSettings: TTSVoiceSettings Voice settings to be used
Returns
string  Returns a the final text to be spoken
GetInvalidError ()
Returns error if invalid
Signature
virtual string Meta.WitAi.TTS.TTSService.GetInvalidError()
Returns
string
GetPresetVoiceSettings ( presetVoiceId )
Return preset voice settings for a specific id
Signature
TTSVoiceSettings Meta.WitAi.TTS.TTSService.GetPresetVoiceSettings(string presetVoiceId)
Parameters
presetVoiceId: string
Returns
TTSVoiceSettings
GetRuntimeCachedClip ( clipID )
Obtain a clip from the runtime cache, if applicable
Signature
TTSClipData Meta.WitAi.TTS.TTSService.GetRuntimeCachedClip(string clipID)
Parameters
clipID: string
Returns
TTSClipData
Load ( textToSpeak , presetVoiceId , diskCacheSettings , onStreamReady , onStreamComplete )
Loads a text-to-speech clip using a preset voice id, specified settings and return methods
Signature
TTSClipData Meta.WitAi.TTS.TTSService.Load(string textToSpeak, string presetVoiceId=null, TTSDiskCacheSettings diskCacheSettings=null, Action< TTSClipData > onStreamReady=null, Action< TTSClipData, string > onStreamComplete=null)
Parameters
textToSpeak: string  Text to be spoken in audio
presetVoiceId: string  Specific id that corresponds to a preset voice setting id
diskCacheSettings: TTSDiskCacheSettings  Custom disk cache options
onStreamReady: Action< TTSClipData >  Callback for stream ready to perform playback
onStreamComplete: Action< TTSClipData, string >  Callback for stream complete
Returns
TTSClipData  Returns the generated tts clip
Load ( textToSpeak , voiceSettings , diskCacheSettings , onStreamReady , onStreamComplete )
Loads a text-to-speech clip using specified settings and return methods
Signature
TTSClipData Meta.WitAi.TTS.TTSService.Load(string textToSpeak, TTSVoiceSettings voiceSettings, TTSDiskCacheSettings diskCacheSettings=null, Action< TTSClipData > onStreamReady=null, Action< TTSClipData, string > onStreamComplete=null)
Parameters
textToSpeak: string  Text to be spoken in audio
voiceSettings: TTSVoiceSettings  Custom voice options
diskCacheSettings: TTSDiskCacheSettings  Custom disk cache options
onStreamReady: Action< TTSClipData >  Callback for stream ready to perform playback
onStreamComplete: Action< TTSClipData, string >  Callback for stream complete
Returns
TTSClipData  Returns the generated tts clip
LoadAsync ( clipData , onStreamReady , onStreamComplete )
Loads a text-to-speech clip using specified settings and return methods
Signature
async Task<string> Meta.WitAi.TTS.TTSService.LoadAsync(TTSClipData clipData, Action< TTSClipData > onStreamReady=null, Action< TTSClipData, string > onStreamComplete=null)
Parameters
clipData: TTSClipData  The clip that will be loaded if needed
onStreamReady: Action< TTSClipData >  Callback for stream ready to perform playback
onStreamComplete: Action< TTSClipData, string >  Callback for stream complete
Returns
async Task< string >  Returns an error
ShouldCacheToDisk ( clipData )
Whether a specific clip should be cached
Signature
bool Meta.WitAi.TTS.TTSService.ShouldCacheToDisk(TTSClipData clipData)
Parameters
clipData: TTSClipData  Clip data
Returns
bool  True if should be cached
Unload ( clipData )
Force a runtime cache unload
Signature
void Meta.WitAi.TTS.TTSService.Unload(TTSClipData clipData)
Parameters
clipData: TTSClipData
Returns
void
UnloadAll ()
Unload all audio clips from the runtime cache
Signature
void Meta.WitAi.TTS.TTSService.UnloadAll()
Returns
void