Class · inherits Instance
AudioTextToSpeech
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 whetherAudioTextToSpeech.Textis automatically translated into the player's language and routed to an appropriate voice.When set to
true,AudioTextToSpeech.Textis automatically translated into the player's language and routed to the most appropriateAudioTextToSpeech.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 theAudioTextToSpeechobject is loaded, buffered, and ready to play.Denotes whether the
AudioTextToSpeechobject is loaded, buffered, and ready to play. Although uncommon,AudioTextToSpeechobjects may have their assets unloaded at runtime if there is extreme memory pressure, in which caseIsLoadedwill become false.IsPlaying
: booleanDenotes whether theAudioTextToSpeechobject is currently playing.Denotes whether the
AudioTextToSpeechobject is currently playing. This property is read-only, but replicates. To play and stop anAudioTextToSpeechobject at runtime, use thePlay()andPause()methods.Looping
: booleanControls whether theAudioTextToSpeechobject loops.Controls whether the
AudioTextToSpeechobject loops when exceeding the end of itsTimeLength.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.Pitchsemitones. 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 byAudioTextToSpeech.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 byAudioTextToSpeech.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.Textinto the player's language and routes it to an appropriate voice whenAudioTextToSpeech.AutoLocalizeistrue.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 ofWiresthat are connected to the specified pin.Returns an array of
Wiresthat are connected to the specified pin.AudioTextToSpeechhas one "Output" pin.GetInputPins
() → ArrayGets the list of pins that aWirecan use inWire.TargetNameto connect to this instance via itsWire.TargetInstanceproperty.Gets the list of pins that a
Wirecan use inWire.TargetNameto connect to this instance via itsWire.TargetInstanceproperty.For
AudioTextToSpeech, there are none.GetOutputPins
() → ArrayGets the list of pins that aWirecan use inWire.SourceNameto connect to this instance via itsWire.SourceInstanceproperty.Gets the list of pins that a
Wirecan use inWire.SourceNameto connect to this instance via itsWire.SourceInstanceproperty.For
AudioTextToSpeech, this isOutputonly.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 theAudioTextToSpeechobject wherever itsTimePositionis.Pauses the
AudioTextToSpeechobject wherever itsTimePositionis. Replicates from server to client.Play
() → ()Plays theAudioTextToSpeechfrom wherever itsTimePositionis.Plays the
AudioTextToSpeechfrom wherever itsTimePositionis. Replicates from server to client.Unload
() → ()Unload the generated speech audio.Frees resources by unloading the generated speech audio.
Events 3
Ended
AudioTextToSpeech.Ended:Connect(function())Fires when theAudioTextToSpeechobject has completed playback and paused.Fires after the
AudioTextToSpeechobject has completed playback and paused. Note this event will not fire for audio withLoopedset totruesince it continues playing upon reaching its end. This event will also not fire when the audio is paused before playback has completed; for this, useAudioTextToSpeech.GetPropertyChangedSignalon theIsPlayingproperty.This event may be used to destroy an
AudioTextToSpeechobject when it has completed playback.Looped
AudioTextToSpeech.Looped:Connect(function())Fires when theAudioTextToSpeechobject loops.Event that fires after the
AudioTextToSpeechobject loops. This happens when the audio reaches the end of its content andLoopingistrue.This event does not fire if the audio is looped manually by changing its
TimePosition.WiringChanged
AudioTextToSpeech.WiringChanged:Connect(function(connected, pin, wire, instance))Fires when another instance is connected to or disconnected from theAudioTextToSpeechvia aWire.Event that fires after a
Wirebecomes connected or disconnected, and thatWireis now or was previously connected to a pin on theAudioTextToSpeechand 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.