Roblox UtilitiesDevlHub Roblox Documentation

Class

AudioTextToSpeech

Inherits
Instance › Object
Memory category
Internal

Plays text as speech audio.

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 11#

IsLoadedbooleanDenotes whether the AudioTextToSpeech object is loaded, buffered, and ready to play.ReadSafeReadOnlyNotReplicated
IsPlayingbooleanDenotes whether the AudioTextToSpeech object is currently playing.Write: RobloxEngineSecurityReadSafe
LoopingbooleanControls whether the AudioTextToSpeech object loops.ReadSafe
PitchfloatControls the pitch of the generated speech audio, which will be independent of its speed.ReadSafe
PlaybackSpeedfloatControls how quickly the speech audio will be played, which controls its pitch.ReadSafe
SpeedfloatControls the speed of the generated speech audio, which will be independent of its pitch.ReadSafe
TextstringThe text to be converted into speech audio by AudioTextToSpeech.ReadSafe
TimeLengthdoubleDenotes the length of the generated speech audio.ReadSafeReadOnlyNotReplicated
TimePositiondoubleTracks the current position of the playhead within the generated speech audio.ReadSafe
VoiceIdstringThe voice style to be used by AudioTextToSpeech.ReadSafe
VolumefloatControls how loudly the generated speech audio will be played.ReadSafe

IsLoaded: boolean#

ReadOnlyNotReplicatedReadSafe

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: boolean#

Write: RobloxEngineSecurityReadSafe

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: boolean#

ReadSafe

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

Pitch: float#

ReadSafe

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: float#

ReadSafe

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

Speed: float#

ReadSafe

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

Text: string#

ReadSafe

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

TimeLength: double#

ReadOnlyNotReplicatedReadSafe

Denotes the generated speech audio in seconds.

TimePosition: double#

ReadSafe

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

VoiceId: string#

ReadSafe

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

Volume: float#

ReadSafe

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#

GetConnectedWiresReturns an array of Wires that are connected to the specified pin.
GetInputPinsGets the list of pins that a Wire can use in Wire.TargetName to connect to this instance via its Wire.TargetInstance property.
GetOutputPinsGets the list of pins that a Wire can use in Wire.SourceName to connect to this instance via its Wire.SourceInstance property.
GetWaveformAsyncReturns a sampling of the waveform data for the generated audio.Yields
LoadAsyncGenerates speech audio.Yields
PausePauses the AudioTextToSpeech object wherever its TimePosition is.
PlayPlays the AudioTextToSpeech from wherever its TimePosition is.
UnloadUnload the generated speech audio.

GetConnectedWires(pin: string): List<Wire>#

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

NameTypeDefaultDescription
pinstringAn input or output pin on this instance
Returns
  • List<Wire> — An array of Wires

GetInputPins(): Array#

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.

Returns
  • Array — An array of strings representing valid pin names.

GetOutputPins(): Array#

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.

Returns
  • Array — An array of strings representing valid pin names.

GetWaveformAsync(timeRange: NumberRange, samples: int): Array#

Yields

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.

NameTypeDefaultDescription
timeRangeNumberRangeThe start and end time (in seconds) of the segment to read.
samplesintThe number of samples to return for the specified range.
Returns
  • Array — A table of samples numbers ranging between -1 and 1 representing the sampled waveform,

LoadAsync(): AssetFetchStatus#

Yields

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.

Returns

Pause(): ()#

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

Returns
  • ()

Play(): ()#

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

Returns
  • ()

Unload(): ()#

Frees resources by unloading the generated speech audio.

Returns
  • ()

Events 3#

EndedFires when the AudioTextToSpeech object has completed playback and paused.
LoopedFires when the AudioTextToSpeech object loops.
WiringChangedFires when another instance is connected to or disconnected from the AudioTextToSpeech via a Wire.

Ended()#

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.

Looped()#

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.

WiringChanged(connected: boolean, pin: string, wire: Wire, instance: Instance)#

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.

NameTypeDefaultDescription
connectedbooleanWhether the instance got connected or disconnected.
pinstringThe pin on the AudioTextToSpeech that the Wire targets.
wireWireThe Wire between the AudioTextToSpeech and the other instance.
instanceInstanceThe other instance that is or was connected through the Wire.

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed