How to make a roblox text to speech?

I have sounds and everything, with chat events and filtering. It’s just the actual ‘speech’ part I don’t understand. Here is the sounds:

Here is the code I have so far:

game.Players.PlayerAdded:Connect(function(player)
local sounds = game.ReplicatedStorage:WaitForChild('TextToSpeechSounds')
local totalsounds = game.ReplicatedStorage:WaitForChild('TextToSpeechSounds'):GetChildren()
print(#totalsounds .. ' sounds loaded!')
player.Chatted:Connect(function(msg)
local hastag = string.gmatch('#',filtered)
if hastag then
	warn 'String flitered, canceling'
else
	
end		
	end)
	end)


  Oh, and in this else that's where I am stuck on. I'm guessing I would get the order of the letters then do string.sub, maybe?
10 Likes

This is something I am every interested in and have my my own attempts at, currently my script can only make basic 1 word sounds but maybe you can use some parts of it. So I will leave it here.

I put this on a server in ServerScript with a sound object attached

game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
	print(Player.Name, Message)
	if Message == "hello" then
	
	
	local helloThereAud = Instance.new("Sound")
	helloThereAud.Parent = Player
	helloThereAud.SoundId = "rbxassetid://4552859397" -- replace with 4552859397 once it loads
	helloThereAud.PlayOnRemove = true
	helloThereAud:Destroy()
	
	elseif Message == "Hello" then
		
	local helloThereAud = Instance.new("Sound")
	helloThereAud.Parent = Player
	helloThereAud.SoundId = "rbxassetid://4552859397"
	helloThereAud.PlayOnRemove = true
	helloThereAud:Destroy()
	
	elseif Message == "Hello there" then
		
	local helloThereAud = Instance.new("Sound")
	helloThereAud.Parent = Player
	helloThereAud.SoundId = "rbxassetid://4550215560"
	helloThereAud.PlayOnRemove = true
	helloThereAud:Destroy()
	
	
	elseif Message == "hello there" then
		
	local helloThereAud = Instance.new("Sound")
	helloThereAud.Parent = Player
	helloThereAud.SoundId = "rbxassetid://4550215560"
	helloThereAud.PlayOnRemove = true
	helloThereAud:Destroy()
	
	elseif Message == "goodbye" then
		
	local helloThereAud = Instance.new("Sound")
	helloThereAud.Parent = Player
	helloThereAud.SoundId = "rbxassetid://4550217403"
	helloThereAud.PlayOnRemove = true
	helloThereAud:Destroy()
	
	elseif Message == "Goodbye" then
		
	local helloThereAud = Instance.new("Sound")
	helloThereAud.Parent = Player
	helloThereAud.SoundId = "rbxassetid://4550217403"
	helloThereAud.PlayOnRemove = true
	helloThereAud:Destroy()
		
	end
end)
end)

Hopefully some part of that could be of use to you as I am very interested in this project, as OutPost 84 have been one of my favorite proof of concept places.

4 Likes

Thanks for the reply, but I don’t want to do the entire dictionary using elseif. So I’m thinking getting the order of the letters the using string.sub, but I’m not sure how that would work. Oh and also, if you do this system then the could type hello many different ways like hElLo or HELLO or HELLO : D or HELLLO HELlo and so on. So using syllable sounds might work better.

2 Likes

oh yeah I know that, I just wanted to see if any of the code at all could be helpful. What you want to do is million times more advanced than my basic script, just seeing if anything sparks idea as I really want to see more text to speech done in Roblox.

1 Like

Well thanks anyways, :smiley: i put this here so its over the 30 character limit

2 Likes

I would recommend using gmatch instead string.sub to play the sound for each letter and so then you could iterate through the string , for example:

local Text = "hello"

for Letter in string.gmatch(Text, ".") do
	--- play the sound for the letter
end
4 Likes

Thank you! (even though I was already using gmatch) I should use a for loop to get the letters :smiley:

1 Like

Also if you were to have sounds pronounced differently in cases were the string is UpperCase or lowercase, string patterns are a great thing to look into if you haven’t already

btw cool project!

2 Likes

Hey there! I’m also trying to get text to speech with a chat bot. Could you provide me with the sounds you used?

Did you ever get the sounds for the text to speech system?

I never did, utill then we will have to wait for Roblox to release an update about it.