Class
AudioTextToSpeech
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#
IsLoadedboolean | Denotes whether the AudioTextToSpeech object is loaded, buffered,
and ready to play.ReadSafeReadOnlyNotReplicated |
IsPlayingboolean | Denotes whether the AudioTextToSpeech object is currently playing.Write: RobloxEngineSecurityReadSafe |
Loopingboolean | Controls whether the AudioTextToSpeech object loops.ReadSafe |
Pitchfloat | Controls the pitch of the generated speech audio, which will be independent of its speed.ReadSafe |
PlaybackSpeedfloat | Controls how quickly the speech audio will be played, which controls its pitch.ReadSafe |
Speedfloat | Controls the speed of the generated speech audio, which will be independent of its pitch.ReadSafe |
Textstring | The text to be converted into speech audio by AudioTextToSpeech.ReadSafe |
TimeLengthdouble | Denotes the length of the generated speech audio.ReadSafeReadOnlyNotReplicated |
TimePositiondouble | Tracks the current position of the playhead within the generated speech audio.ReadSafe |
VoiceIdstring | The voice style to be used by AudioTextToSpeech.ReadSafe |
Volumefloat | Controls 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#
| GetConnectedWires | Returns an array of Wires that are connected to the specified
pin. |
| GetInputPins | Gets the list of pins that a Wire can use in
Wire.TargetName to connect to this instance via its
Wire.TargetInstance property. |
| GetOutputPins | Gets the list of pins that a Wire can use in
Wire.SourceName to connect to this instance via its
Wire.SourceInstance property. |
| GetWaveformAsync | Returns a sampling of the waveform data for the generated audio.Yields |
| LoadAsync | Generates speech audio.Yields |
| Pause | Pauses the AudioTextToSpeech object wherever its
TimePosition is. |
| Play | Plays the AudioTextToSpeech from wherever its
TimePosition is. |
| Unload | Unload 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.
| Name | Type | Default | Description |
|---|---|---|---|
pin | string | An input or output pin on this instance |
Returns
List<Wire>— An array ofWires
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.
| Name | Type | Default | Description |
|---|---|---|---|
timeRange | NumberRange | The start and end time (in seconds) of the segment to read. | |
samples | int | The number of samples to return for the specified range. |
Returns
Array— A table ofsamplesnumbers 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
AssetFetchStatus— AnAssetFetchStatus—Successonce the speech audio has been generated, orFailureif generation could not be completed.
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#
| Ended | Fires when the AudioTextToSpeech object has completed playback and
paused. |
| Looped | Fires when the AudioTextToSpeech object loops. |
| WiringChanged | Fires 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.
| Name | Type | Default | Description |
|---|---|---|---|
connected | boolean | Whether the instance got connected or disconnected. | |
pin | string | The pin on the AudioTextToSpeech that the Wire
targets. | |
wire | Wire | The Wire between the AudioTextToSpeech and the other
instance. | |
instance | Instance | The other instance that is or was connected through the Wire. |
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild