Voice SDK’s Text-to-Speech (TTS) feature uses a Wit.ai service to provide audio files for text strings. It’s handled by a WitTtsSpeaker Blueprint for each scene location in which a TTS clip can be played.
To keep TTS working smoothly, Voice SDK handles the caching of TTS files during runtime to avoid redundant network requests.
To set up TTS for your app, follow these steps:
In Unreal, create a Blueprint class from WitTtsSpeaker.
Add an instance of the WitTtsSpeaker Blueprint to your scene.
In the World Outliner window, select WitTtsSpeaker and adjust the settings to fit your needs:
Go to TTS > Configuration and select the Wit configuration file for your app from the list.
Under Voice Preset, select Update Voice List to refresh the list of voices and voice styles that are available from Wit.ai. For more information, see TTS Voice Customization.
Under TTS Runtime Cache (Script), adjust the settings to indicate how often clips will be automatically unloaded from memory. For more information, see TTS Cache Options.
If needed, adjust your disk cache directory location and name. To do this, go to TTS Cache > Storage > Cache Directory. For more information, see TTS Cache Options.
Add the WitTtsSpeaker Blueprint to each additional location in your app where you would like TTS to be played.
Modify each occurrence of the WitTtsSpeaker Blueprint to reflect specific needs for that location using the Detail window for that occurrence.
Under TTS, select the Voice Preset for the specific speaker.
In the WitTtsSpeaker Blueprints, use the appropriate methods to make any changes needed:
Use the WitTtsSpeaker’s Speak(text) method to request and say specified text.
Use the WitTtsSpeaker’s Stop() method to immediately stop any playing TTS clips.
Open the WitTtsSpeaker Blueprint and add callbacks for the following events:
Select the EventHandler component and expand Events to bind:
OnSynthesizeResponse: fires when speech synthesis completes.
OnSynthesizeError: fires when synthesis encounters an error.
Select the MemoryCache component and expand Events to bind:
OnClipAdded: fires when a clip is added to the memory cache.
OnClipRemoved: fires when a clip is removed from the memory cache.