Text To Speech
TextToSpeech Documentation
The TextToSpeech component allows you to play text-to-speech (TTS) audio from a given text prompt. It can be used to give your Metaverse avatars a voice.
Namespace
MetaverseCloudEngine.Unity.AI.Components
Public Methods
void Play(): Plays the TTS audio from the text prompt.
Public Properties
string Text: The text prompt to convert to speech.
bool PlayOnStart: Whether or not to play the TTS audio when the component starts.
AudioSource VoiceSource: The AudioSource to play the TTS audio from.
TextToSpeechVoicePreset VoicePreset: The voice preset to use for the TTS audio.
Inspector Fields
TextPrompt text: The text prompt to convert to speech.
bool playOnStart: Whether or not to play the TTS audio when the component starts.
AudioSource voiceSource: The AudioSource to play the TTS audio from.
TextToSpeechVoicePreset voicePreset: The voice preset to use for the TTS audio.
Behavior
Execution Order: This class inherits from TriInspectorMonoBehaviour, which uses the default Unity execution order.
Usage
To use TextToSpeech, start by adding the component to a GameObject in your scene.
In the inspector, set the text property to the text prompt that you want to convert to speech.
Optionally, set the voiceSource property to the AudioSource that you want to play the TTS audio from.
Optionally, set the voicePreset property to the voice preset that you want to use.
You can then use the Play() method to play the TTS audio.
Example:
You can use the TextToSpeech component to give your Metaverse avatar a voice. To do this:
Add the TextToSpeech component to the avatar's GameObject.
In the inspector, set the text property to the text that you want the avatar to say.
Set the voiceSource property to the AudioSource that you want to play the TTS audio from.
Call the Play() method to play the TTS audio.
This will play the TTS audio from the specified AudioSource, and the avatar will speak the text that you specified.
Additional Notes
The TextToSpeech component uses a third-party TTS service to convert text to speech.
The TextToSpeechVoicePreset class allows you to select different voices for the TTS audio.
Last updated
Was this helpful?