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

  1. To use TextToSpeech, start by adding the component to a GameObject in your scene.

  2. In the inspector, set the text property to the text prompt that you want to convert to speech.

  3. Optionally, set the voiceSource property to the AudioSource that you want to play the TTS audio from.

  4. Optionally, set the voicePreset property to the voice preset that you want to use.

  5. 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:

  1. Add the TextToSpeech component to the avatar's GameObject.

  2. In the inspector, set the text property to the text that you want the avatar to say.

  3. Set the voiceSource property to the AudioSource that you want to play the TTS audio from.

  4. 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