-
What do you want to achieve?
I want to useAudioTextToSpeechon the server to play quiz questions as text-to-speech without freezing gameplay. -
What is the issue?
CallingAudioTextToSpeech:LoadAsync()on the server never returns in live servers.
Because the call yields, the script thread stalls indefinitely and freezes gameplay logic (for example, intermission timers or round progression). -
What solutions have you tried so far?
- Checked the Creator Hub documentation for
AudioTextToSpeech - Confirmed I am within documented TTS rate limits
- Reused a single
AudioTextToSpeechinstance - Wrapped the call in
pcall(does not help since it yields) - Moved
LoadAsync()into a separate task with a manual timeout as a workaround
local tts = Instance.new("AudioTextToSpeech")
tts.Parent = workspace
tts.Text = "This is a test sentence."
tts.VoiceId = "1"
local output = Instance.new("AudioDeviceOutput")
output.Parent = workspace
local wire = Instance.new("Wire")
wire.Parent = workspace
wire.SourceInstance = tts
wire.TargetInstance = output
print("Before LoadAsync")
-- Never returns in live servers
local status = tts:LoadAsync()
print("After LoadAsync", status)