#Does AudioTextToSpeech (TTS) have a native ReadingSpeed or something similar? (Scripting Help)

1 messages · Page 1 of 1 (latest)

jaunty mango
#

So first off, I have found AudioTextToSpeed.TimeLength to be absolutely unreliable, it's shown me that it would be immediately read as '0' by Roblox, and I have to pretty much calculate my own TimeLength.

So I'm experimenting with the the AudioTextToSpeech thing in Roblox, and I've noticed that some words, despite the length of said word, can be read faster or slower than others. Punctuation does slightly add to the length, but it's not as noticeable.

About what I'm doing:
So in my game I'm using the tts instance to read text. I have multiple text bodies than can be read, and so I have a button that is the colour grey by default. Once it's reading the tts, it turns green.

My goal:
Get TimeLength precise as possible for it to turn back to grey once it's done reading a message. What I'm experiencing is that my current code tries to calculate the TimeLength in place of tts.TimeLength so that I can actually use it the way I need to.

Issue with native tts.TimeLength:
I've found that Roblox's tts doesn't work too well with it's own TimeLength. I initially tested this within a loop to see when the TimeLength is met via the TimePosition.

It would immediately exit my loop, so I printed the TimeLength of the tts.TimeLength and it would always return as '0'. I get that it needs time to load, but it doesn't always work.

#

I added this check:
while tts.TimeLength <= 0 do wait(0.1)
print("It's <= 0.")
end

I remember clicking the button a few times and it would sometimes display the actual tts.TimeLength, but most of the times Roblox would return it as 0. This absolutely has to be some sort of loading/timing issue but it actually doesn't make any sense

#

I made that loop expecting it to run a few times and then exit it once it fully loaded, but I let it run for like a solid 2 minutes before I stopped it.

tts.TimeLength seems absolutely unreliable which is why I turned to trying to make my own tts.TimeLength solution

#

The main issue I've been facing is how fast it reads some words versus others

#

It would be so much easier if we could fetch a word from our selected message body, or just a word in general and do something like print(AudioTextToSpeed:WordSpeed(word)) and give us how fast it would read that word.

So when tts.TimeLength doesn't work like how it's supposed to, I could find another solution by getting all of the words within the message body and doing something like this:

local message = "Hello, this is a Roblox auto narrator!"

local tts = instance.New("AudioTextToSpeech")
tts.VoiceId = "3" --or (1,2)
tts.Text = message
tts.Parent = thing

local ADO = instance.New("AudioDeviceOutput")
ADO.Parent = thing

local wire = instance.New("Wire")
wire.SourceInstance = tts
wire.TargetInstance = ADO

wire.Parent = thing

local totalSpeed = 0

for word in messageBody:gmatch("%S+") do
    --Would definitely be a number
    totalSpeed += tts:WordSpeed(word)
end

--That or whatever
wait(totalSpeed)```
#

So I guess I'm really asking 2 things:

  1. Is there some type of way I can find out how fast it reads a particular word? Even if I have to get a bit unorthodox about it?

  2. Am I doing something wrong or do I have something out of order that doesn't allow for the tts.TimeLength to properly get/set/load and that's why it's either 0 or the proper TimeLength?