Skip to content

Class · inherits Instance

AudioTextToSpeech

Official docs ↗

Plays text as speech audio.

About AudioTextToSpeech

AudioTextToSpeech is used to play text as speech audio. It provides a single Output pin which can be connected to other pins via Wires.

Roblox uses the following formula to throttle requests for this API based on the number of players in your experience: max requests per minute per experience = 1 + (6 * number_of_concurrent_users). You can purchase additional usage using Extended Services.

There is also a client-side throttle of 4 requests per second per user.

For a more in-depth look, see Text-to-speech.

Properties 12

  • AutoLocalize: booleanControls whether AudioTextToSpeech.Text is automatically translated into the player's language and routed to an appropriate voice.

    When set to true, AudioTextToSpeech.Text is automatically translated into the player's language and routed to the most appropriate AudioTextToSpeech.VoiceId. For example, if a female voice ID is used in English, Roblox routes to a female voice for other languages.

    Text-to-speech currently supports automatic translation between the following languages:

    • Arabic
    • Chinese (Mandarin)
    • English
    • French
    • German
    • Hindi
    • Italian
    • Japanese
    • Korean
    • Portuguese
    • Spanish

    Defaults to true.

  • IsLoaded: booleanReadOnlyNotReplicatedDenotes whether the AudioTextToSpeech object is loaded, buffered, and ready to play.

    Denotes whether the AudioTextToSpeech object is loaded, buffered, and ready to play. Although uncommon, AudioTextToSpeech objects may have their assets unloaded at runtime if there is extreme memory pressure, in which case IsLoaded will become false.

  • IsPlaying: booleanDenotes whether the AudioTextToSpeech object is currently playing.

    Denotes whether the AudioTextToSpeech object is currently playing. This property is read-only, but replicates. To play and stop an AudioTextToSpeech object at runtime, use the Play() and Pause() methods.

  • Looping: booleanControls whether the AudioTextToSpeech object loops.

    Controls whether the AudioTextToSpeech object loops when exceeding the end of its TimeLength.

  • Pitch: floatControls the pitch of the generated speech audio, which will be independent of its speed.

    A value in musical semitones. The pitch of the generated speech audio is shifted from its default value by AudioTextToSpeech.Pitch semitones. Ranges from -12.0 to 12.0.

  • PlaybackSpeed: floatControls how quickly the speech audio will be played, which controls its pitch.

    Multiplier controlling how quickly the speech audio will be played, directly controlling its perceived pitch. Ranges from 0 to 20.

  • Speed: floatControls the speed of the generated speech audio, which will be independent of its pitch.

    Multiplier controlling the speed of the generated speech audio. Ranges from 0.5 to 2.0.

  • Text: stringThe text to be converted into speech audio by AudioTextToSpeech.

    The text to be converted into speech audio by AudioTextToSpeech. The text has a maximum length of 300 characters.

  • TimeLength: doubleReadOnlyNotReplicatedDenotes the length of the generated speech audio.

    Denotes the generated speech audio in seconds.

  • TimePosition: doubleTracks the current position of the playhead within the generated speech audio.

    Tracks and controls the current position of the playhead within the generated speech audio, in seconds.

  • VoiceId: stringThe voice style to be used by AudioTextToSpeech.

    The voice style to be used by AudioTextToSpeech. A list of available voices and their corresponding VoiceIds can be found in the list of artificial voices.

    Roblox automatically translates AudioTextToSpeech.Text into the player's language and routes it to an appropriate voice when AudioTextToSpeech.AutoLocalize is true.

  • Volume: floatControls how loudly the generated speech audio will be played.

    Volume level which is multiplied onto the output audio stream, controlling how loudly the generated speech audio will be played. Ranges from 0 to 3.

Methods 8

  • GetConnectedWires(pin: string) → List<Wire>Returns an array of Wires that are connected to the specified pin.

    Returns an array of Wires that are connected to the specified pin. AudioTextToSpeech has one "Output" pin.

  • GetInputPins() → ArrayGets the list of pins that a Wire can use in Wire.TargetName to connect to this instance via its Wire.TargetInstance property.

    Gets the list of pins that a Wire can use in Wire.TargetName to connect to this instance via its Wire.TargetInstance property.

    For AudioTextToSpeech, there are none.

  • GetOutputPins() → ArrayGets the list of pins that a Wire can use in Wire.SourceName to connect to this instance via its Wire.SourceInstance property.

    Gets the list of pins that a Wire can use in Wire.SourceName to connect to this instance via its Wire.SourceInstance property.

    For AudioTextToSpeech, this is Output only.

  • GetWaveformAsync(timeRange: NumberRange, samples: int) → ArrayYieldsReturns a sampling of the waveform data for the generated audio.

    Returns a sampling of the waveform data for the generated text-to-speech audio. This can be used to check the volume of the audio over the course of its duration without playing it.

  • LoadAsync() → AssetFetchStatusYieldsGenerates speech audio.

    A blocking call that begins the generation of speech audio based on the current parameters. It will yield until the speech generation either completes or fails. Status is returned by an AssetFetchStatus value.

  • Pause() → ()Pauses the AudioTextToSpeech object wherever its TimePosition is.

    Pauses the AudioTextToSpeech object wherever its TimePosition is. Replicates from server to client.

  • Play() → ()Plays the AudioTextToSpeech from wherever its TimePosition is.

    Plays the AudioTextToSpeech from wherever its TimePosition is. Replicates from server to client.

  • Unload() → ()Unload the generated speech audio.

    Frees resources by unloading the generated speech audio.

Events 3

  • EndedAudioTextToSpeech.Ended:Connect(function())Fires when the AudioTextToSpeech object has completed playback and paused.

    Fires after the AudioTextToSpeech object has completed playback and paused. Note this event will not fire for audio with Looped set to true since it continues playing upon reaching its end. This event will also not fire when the audio is paused before playback has completed; for this, use AudioTextToSpeech.GetPropertyChangedSignal on the IsPlaying property.

    This event may be used to destroy an AudioTextToSpeech object when it has completed playback.

  • LoopedAudioTextToSpeech.Looped:Connect(function())Fires when the AudioTextToSpeech object loops.

    Event that fires after the AudioTextToSpeech object loops. This happens when the audio reaches the end of its content and Looping is true.

    This event does not fire if the audio is looped manually by changing its TimePosition.

  • WiringChangedAudioTextToSpeech.WiringChanged:Connect(function(connected, pin, wire, instance))Fires when another instance is connected to or disconnected from the AudioTextToSpeech via a Wire.

    Event that fires after a Wire becomes connected or disconnected, and that Wire is now or was previously connected to a pin on the AudioTextToSpeech and to some other wirable instance.

AudioTextToSpeech also has every member of Instance. Deprecated and Roblox-only members are hidden.

Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.